在c#一樣的檔案只花300ms
只好踏上尋找更快開檔方法之路(是誰說C++程式效率很好的...)
ifstream myfile("text.asc");
stringstream ss;
while (getline(myfile, line)) { ss << line; }
為了加快檔案讀取的速度,找了個方法說要加大stream的buffer的buffer size
加入了以下code
const int MySize = 1024 * 1024; char MrBuf[MySize]; ifstream myfile("text.asc"); myfile.rdbuf()->pubsetbuf(MrBuf, MySize);但卻出現stack overflow的 error
先加大stack試試
參考MSDN,在project>properties>C/C++>Command line加入/F sizeInBytes
然後在Linker>System>Stack Reserve Size加入需要的buffer size
這方法的確讓stack overflow error 消失
but...
讀檔速度一樣慢啊...
沒有留言:
張貼留言