生成用例
这是针对单行用例的,但是在实际用例中,我关心多行。在
#include "tchar.h"
#include "stdio.h"
#include "stdlib.h"
#include <string>
#include <sstream>
#include <iostream>
#include <fstream>
#include <ctime>
using namespace std;
void main(void){
ofstream testfile;
unsigned int line_idx = 0;
testfile.open("testfile.txt");
for(line_idx = 0; line_idx < 50000u; line_idx++)
{
if(line_idx != 43268u )
{
testfile << line_idx << " dontcare" << std::endl;
}
else
{
testfile << line_idx << " care" << std::endl;
}
}
testfile.close();
}
正则表达式
使用正则表达式^(\d*)\s(care)$
Python程序耗时0.02200秒
^{3}$
执行Ratah对8.923的建议
通过将文件读入单个字符串,大约5秒的时间提高
在UKMonkey的注释之后,将项目重新配置为发布,其中还包括\O2,并将其降低到0.086秒
感谢Jean Francois Fabre,Ratah,Ukmankey
相关问题 更多 >
编程相关推荐