34#include <wx/wfstream.h> 
   35#include <wx/filename.h> 
   41using CLOCK = std::chrono::steady_clock;
 
   42using TIME_PT = std::chrono::time_point<CLOCK>;
 
   79    for( 
int i = 0; i < aReps; ++i)
 
   81        std::ifstream fstr( aFile.GetFullPath().fn_str() );
 
   83        while( getline( fstr, line ) )
 
   86            report.
charAcc += (
unsigned char) line[0];
 
 
  101    std::ifstream fstr( aFile.GetFullPath().fn_str() );
 
  103    for( 
int i = 0; i < aReps; ++i)
 
  105        while( getline( fstr, line ) )
 
  108            report.
charAcc += (
unsigned char) line[0];
 
  111        fstr.seekg(0, std::ios::beg) ;
 
 
  125    for( 
int i = 0; i < aReps; ++i)
 
  127        LR fstr( aFile.GetFullPath() );
 
  128        while( fstr.ReadLine() )
 
  131            report.
charAcc += (
unsigned char) fstr.Line()[0];
 
 
  144    LR fstr( aFile.GetFullPath() );
 
  145    for( 
int i = 0; i < aReps; ++i)
 
  148        while( fstr.ReadLine() )
 
  151            report.
charAcc += (
unsigned char) fstr.Line()[0];
 
 
  165    for( 
int i = 0; i < aReps; ++i)
 
  167        std::ifstream ifs( aFile.GetFullPath().ToStdString() );
 
  168        std::string content((std::istreambuf_iterator<char>(ifs)),
 
  169            std::istreambuf_iterator<char>());
 
 
  190    std::ifstream ifs( aFile.GetFullPath().ToStdString() );
 
  191    std::string content((std::istreambuf_iterator<char>(ifs)),
 
  192        std::istreambuf_iterator<char>());
 
  194    for( 
int i = 0; i < aReps; ++i)
 
 
  214    S fileStream( aFile.GetFullPath() );
 
  216    for( 
int i = 0; i < aReps; ++i)
 
  226        fileStream.SeekI( 0 );
 
 
  239    S fileStream( aFile.GetFullPath() );
 
  242    for( 
int i = 0; i < aReps; ++i)
 
  250        fileStream.SeekI( 0 );
 
 
  260template<
typename WXIS>
 
  263    WXIS fileStream( aFile.GetFullPath() );
 
  264    wxBufferedInputStream bufferedStream( fileStream );
 
  266    for( 
int i = 0; i < aReps; ++i)
 
  276        fileStream.SeekI( 0 );
 
 
  286template<
typename WXIS>
 
  289    WXIS fileStream( aFile.GetFullPath() );
 
  290    wxBufferedInputStream bufferedStream( fileStream );
 
  294    for( 
int i = 0; i < aReps; ++i)
 
  302        fileStream.SeekI( 0 );
 
 
  340        flags << bmark.triggerChar;
 
 
  356        desc << 
"    " << bmark.triggerChar << 
": " << bmark.name << 
"\n";
 
 
  364        const wxFileName& aFilename )
 
  369    aBenchmark.
func( aFilename, aReps, report );
 
  372    using std::chrono::milliseconds;
 
  373    using std::chrono::duration_cast;
 
  375    report.
benchDurMs = duration_cast<milliseconds>( 
end - start );
 
 
  383    auto& os = std::cout;
 
  387        os << 
"Usage: " << argv[0] << 
" <FILE> <REPS> [" << 
getBenchFlags() << 
"]\n\n";
 
  388        os << 
"Benchmarks:\n";
 
  393    wxFileName inFile( argv[1] );
 
  396    wxString( argv[2] ).ToLong( &reps );
 
  403    os << 
"IO Bench Mark Util" << std::endl;
 
  405    os << 
"  Benchmark file: " << inFile.GetFullPath() << std::endl;
 
  406    os << 
"  Repetitions:    " << (int) reps << std::endl;
 
  411        if( bench.size() && !bench.Contains( bmark.triggerChar ) )
 
  416        os << wxString::Format( 
"%-30s %u lines, acc: %u in %u ms",
 
 
  427        "Benchmark various kinds of IO methods",
 
char * Line() const
Return a pointer to the last line that was read in.
 
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
 
char * ReadLine() override
Read a line of text into the buffer and increments the line number counter.
 
static bool Register(const KI_TEST::UTILITY_PROGRAM &aProgInfo)
Register a utility program factory function against an ID string.
 
static void bench_fstream_reuse(const wxFileName &aFile, int aReps, BENCH_REPORT &report)
Benchmark using a raw std::ifstream, with no LINE_READER wrapper.
 
int io_benchmark_func(int argc, char *argv[])
 
static void bench_line_reader(const wxFileName &aFile, int aReps, BENCH_REPORT &report)
Benchmark using a given LINE_READER implementation.
 
static wxString getBenchFlags()
Construct string of all flags used for specifying benchmarks on the command line.
 
BENCH_REPORT executeBenchMark(const BENCHMARK &aBenchmark, int aReps, const wxFileName &aFilename)
 
static void bench_wxis_reuse(const wxFileName &aFile, int aReps, BENCH_REPORT &report)
Benchmark using an INPUTSTREAM_LINE_READER with a given wxInputStream implementation.
 
static void bench_line_reader_reuse(const wxFileName &aFile, int aReps, BENCH_REPORT &report)
Benchmark using a given LINE_READER implementation.
 
std::function< void(const wxFileName &, int, BENCH_REPORT &)> BENCH_FUNC
 
static void bench_wxbis(const wxFileName &aFile, int aReps, BENCH_REPORT &report)
Benchmark using a INPUTSTREAM_LINE_READER with a given wxInputStream implementation,...
 
static void bench_string_lr_reuse(const wxFileName &aFile, int aReps, BENCH_REPORT &report)
Benchmark using STRING_LINE_READER on string data read into memory from a file using std::ifstream.
 
static void bench_wxbis_reuse(const wxFileName &aFile, int aReps, BENCH_REPORT &report)
Benchmark using a INPUTSTREAM_LINE_READER with a given wxInputStream implementation,...
 
std::chrono::time_point< CLOCK > TIME_PT
 
static void bench_string_lr(const wxFileName &aFile, int aReps, BENCH_REPORT &report)
Benchmark using STRING_LINE_READER on string data read into memory from a file using std::ifstream,...
 
std::chrono::steady_clock CLOCK
 
static void bench_fstream(const wxFileName &aFile, int aReps, BENCH_REPORT &report)
Benchmark using a raw std::ifstream, with no LINE_READER wrapper.
 
static std::vector< BENCHMARK > benchmarkList
List of available benchmarks.
 
static void bench_wxis(const wxFileName &aFile, int aReps, BENCH_REPORT &report)
Benchmark using an INPUTSTREAM_LINE_READER with a given wxInputStream implementation.
 
static wxString getBenchDescriptions()
Usage description of a benchmakr spec.
 
@ BAD_CMDLINE
The command line was not correct for the tool.
 
unsigned charAcc
Char accumulator, used to prevent compilers optimising away otherwise unused line buffers,...
 
std::chrono::milliseconds benchDurMs