1 // Bench.h
2 
3 #ifndef __7ZIP_BENCH_H
4 #define __7ZIP_BENCH_H
5 
6 #include "../../../Windows/System.h"
7 
8 #include "../../Common/CreateCoder.h"
9 #include "../../UI/Common/Property.h"
10 
11 struct CBenchInfo
12 {
13   UInt64 GlobalTime;
14   UInt64 GlobalFreq;
15   UInt64 UserTime;
16   UInt64 UserFreq;
17   UInt64 UnpackSize;
18   UInt64 PackSize;
19   UInt64 NumIterations;
20 
CBenchInfoCBenchInfo21   CBenchInfo(): NumIterations(0) {}
22   UInt64 GetUsage() const;
23   UInt64 GetRatingPerUsage(UInt64 rating) const;
24   UInt64 GetSpeed(UInt64 numCommands) const;
25 };
26 
27 struct IBenchCallback
28 {
29   virtual HRESULT SetFreq(bool showFreq, UInt64 cpuFreq) = 0;
30   virtual HRESULT SetEncodeResult(const CBenchInfo &info, bool final) = 0;
31   virtual HRESULT SetDecodeResult(const CBenchInfo &info, bool final) = 0;
32 };
33 
34 UInt64 GetCompressRating(UInt32 dictSize, UInt64 elapsedTime, UInt64 freq, UInt64 size);
35 UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt64 numIterations);
36 
37 const unsigned kBenchMinDicLogSize = 18;
38 
39 UInt64 GetBenchMemoryUsage(UInt32 numThreads, UInt32 dictionary, bool totalBench = false);
40 
41 struct IBenchPrintCallback
42 {
43   virtual void Print(const char *s) = 0;
44   virtual void NewLine() = 0;
45   virtual HRESULT CheckBreak() = 0;
46 };
47 
48 /*
49 struct IBenchFreqCallback
50 {
51   virtual void AddCpuFreq(UInt64 freq) = 0;
52 };
53 */
54 
55 HRESULT Bench(
56     DECL_EXTERNAL_CODECS_LOC_VARS
57     IBenchPrintCallback *printCallback,
58     IBenchCallback *benchCallback,
59     // IBenchFreqCallback *freqCallback,
60     const CObjectVector<CProperty> &props,
61     UInt32 numIterations,
62     bool multiDict
63     );
64 
65 AString GetProcessThreadsInfo(const NWindows::NSystem::CProcessAffinity &ti);
66 
67 void GetSysInfo(AString &s1, AString &s2);
68 void GetCpuName(AString &s);
69 void GetCpuFeatures(AString &s);
70 
71 
72 #endif
73