1// BenchCon.cpp
2
3#include "StdAfx.h"
4
5#include "../Common/Bench.h"
6
7#include "BenchCon.h"
8#include "ConsoleClose.h"
9
10struct CPrintBenchCallback: public IBenchPrintCallback
11{
12  FILE *_file;
13
14  void Print(const char *s);
15  void NewLine();
16  HRESULT CheckBreak();
17};
18
19void CPrintBenchCallback::Print(const char *s)
20{
21  fputs(s, _file);
22}
23
24void CPrintBenchCallback::NewLine()
25{
26  Print("\n");
27}
28
29HRESULT CPrintBenchCallback::CheckBreak()
30{
31  return NConsoleClose::TestBreakSignal() ? E_ABORT: S_OK;
32}
33
34HRESULT BenchCon(DECL_EXTERNAL_CODECS_LOC_VARS
35    const CObjectVector<CProperty> &props, UInt32 numIterations, FILE *f)
36{
37  CPrintBenchCallback callback;
38  callback._file = f;
39  callback.NewLine();
40  return Bench(EXTERNAL_CODECS_LOC_VARS
41      &callback, NULL, props, numIterations, true);
42}
43