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
|
// BenchmarkDialog.h
#ifndef __BENCHMARK_DIALOG_H
#define __BENCHMARK_DIALOG_H
#include "Windows/Synchronization.h"
#include "Windows/Control/ComboBox.h"
#include "../Common/Bench.h"
#include "../FileManager/DialogSize.h"
#include "BenchmarkDialogRes.h"
struct CBenchInfo2 : public CBenchInfo
{
void Init() { GlobalTime = UserTime = 0; }
};
class CProgressSyncInfo
{
public:
bool Stopped;
bool Paused;
bool Changed;
UInt32 DictionarySize;
UInt32 NumThreads;
UInt64 NumPasses;
// UInt64 NumErrors;
NWindows::NSynchronization::CManualResetEvent _startEvent;
NWindows::NSynchronization::CCriticalSection CS;
CBenchInfo2 CompressingInfoTemp;
CBenchInfo2 CompressingInfo;
UInt64 ProcessedSize;
CBenchInfo2 DecompressingInfoTemp;
CBenchInfo2 DecompressingInfo;
CProgressSyncInfo()
{
if (_startEvent.Create() != S_OK)
throw 3986437;
}
void Init()
{
Changed = false;
Stopped = false;
Paused = false;
CompressingInfoTemp.Init();
CompressingInfo.Init();
ProcessedSize = 0;
DecompressingInfoTemp.Init();
DecompressingInfo.Init();
NumPasses = 0;
// NumErrors = 0;
}
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;
NWindows::NControl::CComboBox m_NumThreads;
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 PrintUsage(UInt64 usage, UINT controlID);
void PrintResults(
UINT32 dictionarySize,
const CBenchInfo2 &info, UINT usageID, UINT speedID, UINT rpuID, UINT ratingID,
bool decompressMode = false);
UInt32 GetNumberOfThreads();
UInt32 OnChangeDictionary();
void OnChangeSettings();
public:
CProgressSyncInfo Sync;
CBenchmarkDialog(): _timer(0) {}
INT_PTR Create(HWND wndParent = 0)
{
BIG_DIALOG_SIZE(332, 228);
return CModalDialog::Create(SIZED_DIALOG(IDD_DIALOG_BENCHMARK), wndParent);
}
void MessageBoxError(LPCWSTR message)
{
MessageBoxW(*this, message, L"7-Zip", MB_ICONERROR);
}
};
HRESULT Benchmark(
DECL_EXTERNAL_CODECS_LOC_VARS
UInt32 numThreads, UInt32 dictionarySize, HWND hwndParent = NULL);
#endif
|