3 ms·
How is the std string version taking over 450 MB for two copies (original and split into lines) of a 210 kB file?
by tspiteri 9y ago
How is the std string version taking over 450 MB for two copies (original and split into lines) of a 210 kB file?
- a_t48 9y agoProbably because his benchmark is broken. It always copies to the end of the file. https://github.com/btwael/SuperString/blob/master/test/withStd.cc#L26 https://github.com/btwael/SuperString/blob/master/test/withS... this line should be ` lines.push_back(string.substr(last, i - last));` (it also drops the very last line, but who's counting, eh?). If the 210kb file has a line every 80 bytes or so and is copied this way, it works out to around 490MB of data (caveat: my math may be wrong).
- tspiteri 9y agoIn that case it's closer to 50 bytes I think. (Average wrong line length is 105k, as first line is 210k and last line is 0k, so number of lines is 450M / 105k (about 4300), so lines would be 210 / 4.3 = about 50 bytes.)