Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

16 Commits

Repository files navigation

File-Reading

Do a study on various file reading techniques in C and C++

Objective

Benchmark various file-reading techniques and test some theories about code runtimes relative to each other:

  • Read a large file and store all the new lines in a vector of string for further processing.
  • Can be any C++ standard or level of optimization during compile.
  • Cross-platform in Windows and Linux.

We will take the average from multiple runs for each function and determine the smallest runtime. Also show a graph of performance for various sizes.

Setup

  • Windows 10 WSL Ubuntu 22.04, g++ 11.4
  • Windows 10 version 19045.3570
  • C++14

Results

Method of ReadingRun #1Run #2Run #3Run #4Run #5Run #6Run #7Run #8Run #9Run #10
grep_newlines_read_line_by_line_and_reserve7.357.447.477.377.487.397.357.377.407.39
istreambuf_reserve_and_readfile_directly_line_by_line262.05244.67245.46262.08245.31261.94262.05262.08262.29261.94
istream_reserve_and_readfile_directly_line_by_line114.48115.50115.79114.86115.53114.72114.48114.86114.66114.72
istreambuf_read_into_reserved_ss_and_get_wholefile_and_reserve305.11282.87286.13304.79282.17304.64305.11304.79305.00304.64
istreambuf_read_into_reserved_ss_and_get_wholefile305.41283.20288.21305.39282.33305.23305.41305.39305.45305.23
istreambuf_read_into_ss_and_get_wholefile_and_reserve285.87264.86268.04285.73263.54285.68285.87285.73286.11285.68
ifstream_read_wholefile_into_charlist_and_reserve15.6116.7319.4214.4517.4015.7115.6114.4514.6115.71
ifstream_read_wholefile_into_charlist6.686.816.806.726.716.726.686.726.736.72
read_FILE_wholefile_and_reserve10.8211.0111.0310.8510.8310.8410.8210.8510.8710.84
read_FILE_wholefile10.9011.0011.1010.8610.9610.8110.9010.8610.8510.81
istreambuf_read_into_ss_and_get_wholefile285.73265.45264.96285.47262.72285.64285.73285.47288.55285.64
istreambuf_copy_to_string_then_read_into_ss_and_get_wholefile285.95266.24266.76285.72262.94285.71285.95285.72289.50285.71
ifstream_and_read_line_by_line13.1113.0415.5811.9713.7812.8513.1111.9714.0212.85
read_FILE_line_by_line_and_reserve40.3840.3841.5040.1640.2140.3040.3840.1640.7240.30
read_FILE_line_by_line7.497.658.157.487.597.507.497.487.657.50

Further study

  • add nmap
  • incorporate community feedback
  • add delimeter separation for each line and add multi-threading to check if that's faster

About

Automation testing and function calls for projects involving IO subroutines and file-reading.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages