Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BenchmarkDialog.h « BenchmarkDialog « Resource « FileManager « 7zip « CPP - github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 244e7fe5f2cc239fb1b084d3b9c91a5d16bf40c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// BenchmarkDialog.h

#ifndef __BENCHMARKDIALOG_H
#define __BENCHMARKDIALOG_H

#include "resource.h"

#include "Common/MyCom.h"
#include "Windows/Control/Dialog.h"
#include "Windows/Control/ComboBox.h"
#include "Windows/Synchronization.h"
#include "../../../ICoder.h"

const int kNumBenchDictionaryBitsStart = 21;

struct CProgressInfo
{
  UINT64 InSize;
  UINT64 OutSize;
  UINT64 Time;
  void Init()
  {
    InSize = 0;
    OutSize = 0;
    Time = 0;
  }
};

class CProgressSyncInfo
{
  bool Stopped;
  bool Paused;
public:
  bool Changed;
  UINT32 DictionarySize;
  bool MultiThread;
  UINT64 NumPasses;
  UINT64 NumErrors;
  NWindows::NSynchronization::CManualResetEvent _startEvent;
  NWindows::NSynchronization::CCriticalSection CS;

  CProgressInfo ApprovedInfo;
  CProgressInfo CompressingInfoPrev;
  CProgressInfo CompressingInfoTemp;
  CProgressInfo CompressingInfo;
  UINT64 ProcessedSize;

  CProgressInfo DecompressingInfoTemp;
  CProgressInfo DecompressingInfo;

  void Init()
  {
    Changed = false;
    ApprovedInfo.Init();
    CompressingInfoPrev.Init();
    CompressingInfoTemp.Init();
    CompressingInfo.Init();
    ProcessedSize = 0;
    
    DecompressingInfoTemp.Init();
    DecompressingInfo.Init();

    Stopped = false;
    Paused = false;
    NumPasses = 0;
    NumErrors = 0;
  }
  void InitSettings()
  {
    DictionarySize = (1 << kNumBenchDictionaryBitsStart);
    MultiThread = false;
  }
  void Stop()
  {
    NWindows::NSynchronization::CCriticalSectionLock lock(CS);
    Stopped = true;
  }
  bool WasStopped()
  {
    NWindows::NSynchronization::CCriticalSectionLock lock(CS);
    return Stopped;
  }
  void Pause()
  {
    NWindows::NSynchronization::CCriticalSectionLock lock(CS);
    Paused = true;
  }
  void Start()
  {
    NWindows::NSynchronization::CCriticalSectionLock lock(CS);
    Paused = false;
  }
  bool WasPaused()
  {
    NWindows::NSynchronization::CCriticalSectionLock lock(CS);
    return Paused;
  }
  void WaitCreating() { _startEvent.Lock(); }
};

class CBenchmarkDialog: 
  public NWindows::NControl::CModalDialog
{
  NWindows::NControl::CComboBox m_Dictionary;
  UINT_PTR _timer;
  UINT32 _startTime;

  bool OnTimer(WPARAM timerID, LPARAM callback);
  virtual bool OnInit();
  void OnRestartButton();
  void OnStopButton();
  void OnHelp();
  virtual void OnCancel();
  bool OnButtonClicked(int buttonID, HWND buttonHWND);
  bool OnCommand(int code, int itemID, LPARAM lParam);

  void PrintTime();
  void PrintRating(UINT64 rating, UINT controlID);
  void PrintResults(
      UINT32 dictionarySize,
      UINT64 elapsedTime, 
      UINT64 size, UINT speedID, UINT ratingID, 
      bool decompressMode = false, UINT64 secondSize = 0);

  UINT32 OnChangeDictionary();
  void OnChangeSettings();
public:
  CProgressSyncInfo _syncInfo;

  CBenchmarkDialog(): _timer(0) {}
  INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_BENCHMARK, wndParent); }
};

void Benchmark(HWND hwnd);

#endif