我写了一个处理GPU上数据的应用程序.代码运行良好,但我有一个问题,输入文件的读取部分(~3GB,文本)是我的应用程序的瓶颈.(从HDD读取速度很快,但逐行处理很慢).
我用getline()读取一行,将第1行复制到向量,将第2行复制到向量,并跳过第3和第4行.依此类推其余11条mio行.
我尝试了几种方法来尽可能地获取文件:
我发现最快的方法是使用boost :: iostreams :: stream
其他人是:
任何建议如何让它运行得更快?
void readfastq(char *filename, int SRlength, uint32_t blocksize){
_filelength = 0; //total datasets (each 4 lines)
_SRlength = SRlength; //length of the 2. line
_blocksize = blocksize;
boost::iostreams::stream<boost::iostreams::file_source>ins(filename);
in = ins;
readNextBlock();
}
void readNextBlock() {
timeval start, end;
gettimeofday(&start, 0);
string name;
string seqtemp;
string garbage;
string phredtemp;
_seqs.empty();
_phred.empty();
_names.empty();
_filelength = 0;
//read only a part of the file i.e the first 4mio lines
while (std::getline(in, …Run Code Online (Sandbox Code Playgroud)