Update to 7-Zip Version 21.03

This commit is contained in:
Tino Reichardt
2021-08-25 22:33:02 +02:00
parent 27d965fd99
commit df06f31a42
90 changed files with 6003 additions and 1882 deletions

View File

@@ -1405,11 +1405,13 @@ void CArcCmdLineParser::Parse2(CArcCmdLineOptions &options)
else if (options.Command.CommandType == NCommandType::kBenchmark)
{
options.NumIterations = 1;
options.NumIterations_Defined = false;
if (curCommandIndex < numNonSwitchStrings)
{
if (!StringToUInt32(nonSwitchStrings[curCommandIndex], options.NumIterations))
throw CArcCmdLineException("Incorrect number of benchmark iterations", nonSwitchStrings[curCommandIndex]);
curCommandIndex++;
options.NumIterations_Defined = true;
}
}
else if (options.Command.CommandType == NCommandType::kHash)

View File

@@ -109,6 +109,7 @@ struct CArcCmdLineOptions
// Benchmark
UInt32 NumIterations;
bool NumIterations_Defined;
CArcCmdLineOptions():
HelpMode(false),

View File

File diff suppressed because it is too large Load Diff

View File

@@ -8,6 +8,8 @@
#include "../../Common/CreateCoder.h"
#include "../../UI/Common/Property.h"
UInt64 Benchmark_GetUsage_Percents(UInt64 usage);
struct CBenchInfo
{
UInt64 GlobalTime;
@@ -17,26 +19,71 @@ struct CBenchInfo
UInt64 UnpackSize;
UInt64 PackSize;
UInt64 NumIterations;
/*
during Code(): we track benchInfo only from one thread (theads with index[0])
NumIterations means number of threads
UnpackSize and PackSize are total sizes of all iterations of current thread
after Code():
NumIterations means the number of Iterations
UnpackSize and PackSize are total sizes of all threads
*/
CBenchInfo(): NumIterations(0) {}
UInt64 GetUsage() const;
UInt64 GetRatingPerUsage(UInt64 rating) const;
UInt64 GetSpeed(UInt64 numCommands) const;
UInt64 GetSpeed(UInt64 numUnits) const;
UInt64 GetUnpackSizeSpeed() const { return GetSpeed(UnpackSize * NumIterations); }
UInt64 Get_UnpackSize_Full() const { return UnpackSize * NumIterations; }
UInt64 GetRating_LzmaEnc(UInt64 dictSize) const;
UInt64 GetRating_LzmaDec() const;
};
struct CTotalBenchRes
{
// UInt64 NumIterations1; // for Usage
UInt64 NumIterations2; // for Rating / RPU
UInt64 Rating;
UInt64 Usage;
UInt64 RPU;
UInt64 Speed;
void Init() { /* NumIterations1 = 0; */ NumIterations2 = 0; Rating = 0; Usage = 0; RPU = 0; Speed = 0; }
void SetSum(const CTotalBenchRes &r1, const CTotalBenchRes &r2)
{
Rating = (r1.Rating + r2.Rating);
Usage = (r1.Usage + r2.Usage);
RPU = (r1.RPU + r2.RPU);
Speed = (r1.Speed + r2.Speed);
// NumIterations1 = (r1.NumIterations1 + r2.NumIterations1);
NumIterations2 = (r1.NumIterations2 + r2.NumIterations2);
}
void Generate_From_BenchInfo(const CBenchInfo &info);
void Mult_For_Weight(unsigned weight);
void Update_With_Res(const CTotalBenchRes &r);
};
struct IBenchCallback
{
virtual HRESULT SetFreq(bool showFreq, UInt64 cpuFreq) = 0;
// virtual HRESULT SetFreq(bool showFreq, UInt64 cpuFreq) = 0;
virtual HRESULT SetEncodeResult(const CBenchInfo &info, bool final) = 0;
virtual HRESULT SetDecodeResult(const CBenchInfo &info, bool final) = 0;
};
UInt64 GetCompressRating(UInt32 dictSize, UInt64 elapsedTime, UInt64 freq, UInt64 size);
UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt64 numIterations);
const unsigned kBenchMinDicLogSize = 18;
UInt64 GetBenchMemoryUsage(UInt32 numThreads, UInt32 dictionary, bool totalBench = false);
UInt64 GetBenchMemoryUsage(UInt32 numThreads, int level, UInt64 dictionary, bool totalBench);
struct IBenchPrintCallback
{
@@ -45,22 +92,20 @@ struct IBenchPrintCallback
virtual HRESULT CheckBreak() = 0;
};
/*
struct IBenchFreqCallback
{
virtual void AddCpuFreq(UInt64 freq) = 0;
virtual HRESULT AddCpuFreq(unsigned numThreads, UInt64 freq, UInt64 usage) = 0;
virtual HRESULT FreqsFinished(unsigned numThreads) = 0;
};
*/
HRESULT Bench(
DECL_EXTERNAL_CODECS_LOC_VARS
IBenchPrintCallback *printCallback,
IBenchCallback *benchCallback,
// IBenchFreqCallback *freqCallback,
const CObjectVector<CProperty> &props,
UInt32 numIterations,
bool multiDict
);
bool multiDict,
IBenchFreqCallback *freqCallback = NULL);
AString GetProcessThreadsInfo(const NWindows::NSystem::CProcessAffinity &ti);

View File

@@ -272,7 +272,11 @@ void Benchmark(bool totalMode)
prop.Value = "*";
props.Add(prop);
}
result = Benchmark(EXTERNAL_CODECS_VARS_L props, g_HWND);
result = Benchmark(
EXTERNAL_CODECS_VARS_L
props,
k_NumBenchIterations_Default,
g_HWND);
MY_TRY_FINISH
}

View File

@@ -128,7 +128,7 @@ static const char * const kHelpString =
#ifndef _NO_CRYPTO
" -p{Password} : set Password\n"
#endif
" -r[-|0] : Recurse subdirectories\n"
" -r[-|0] : Recurse subdirectories for name search\n"
" -sa{a|e|s} : set Archive name mode\n"
" -scc{UTF-8|WIN|DOS} : set charset for for console input/output\n"
" -scs{UTF-8|UTF-16LE|UTF-16BE|WIN|DOS|{id}} : set charset for list files\n"
@@ -200,63 +200,55 @@ static void ShowProgInfo(CStdOutStream *so)
#endif
*/
#ifdef __VERSION__
<< " compiler: " << __VERSION__
#endif
#ifdef __GNUC__
<< " GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__
#endif
#ifdef __clang__
<< " CLANG " << __clang_major__ << "." << __clang_minor__
#endif
#ifdef __xlC__
<< " XLC " << (__xlC__ >> 8) << "." << (__xlC__ & 0xFF)
#ifdef __xlC_ver__
<< "." << (__xlC_ver__ >> 8) << "." << (__xlC_ver__ & 0xFF)
#endif
#endif
#ifdef _MSC_VER
<< " MSC " << _MSC_VER
#endif
#ifdef __ARM_FEATURE_CRC32
<< " CRC32"
#endif
<< " " << (unsigned)(sizeof(void *)) * 8 << "-bit"
#ifdef __ILP32__
<< " ILP32"
#endif
#ifdef __ARM_ARCH
<< " arm_v:" << __ARM_ARCH
#ifdef __ARM_ARCH_ISA_THUMB
<< " thumb:" << __ARM_ARCH_ISA_THUMB
#endif
#endif
;
#ifdef ENV_HAVE_LOCALE
<< " locale=" << GetLocale()
*so << " locale=" << GetLocale();
#endif
#ifndef _WIN32
<< " UTF8=" << (IsNativeUTF8() ? "+" : "-")
<< " use-UTF8=" << (g_ForceToUTF8 ? "+" : "-")
<< " wchar_t=" << (unsigned)(sizeof(wchar_t)) * 8 << "-bit"
<< " Files=" << (unsigned)(sizeof(off_t)) * 8 << "-bit"
{
const bool is_IsNativeUTF8 = IsNativeUTF8();
if (!is_IsNativeUTF8)
*so << " UTF8=" << (is_IsNativeUTF8 ? "+" : "-");
}
if (!g_ForceToUTF8)
*so << " use-UTF8=" << (g_ForceToUTF8 ? "+" : "-");
{
const unsigned wchar_t_size = (unsigned)sizeof(wchar_t);
if (wchar_t_size != 4)
*so << " wchar_t=" << wchar_t_size * 8 << "-bit";
}
{
const unsigned off_t_size = (unsigned)sizeof(off_t);
if (off_t_size != 8)
*so << " Files=" << off_t_size * 8 << "-bit";
}
#endif
;
{
const UInt32 numCpus = NWindows::NSystem::GetNumberOfProcessors();
*so << " Threads:" << numCpus;
}
#ifdef _7ZIP_ASM
*so << ", ASM";
#endif
/*
{
AString s;
GetCpuName(s);
@@ -264,9 +256,10 @@ static void ShowProgInfo(CStdOutStream *so)
*so << ", " << s;
}
#ifdef _7ZIP_ASM
*so << ",ASM";
#ifdef __ARM_FEATURE_CRC32
<< " CRC32"
#endif
#if (defined MY_CPU_X86_OR_AMD64 || defined(MY_CPU_ARM_OR_ARM64))
if (CPU_IsSupported_AES()) *so << ",AES";
@@ -281,6 +274,7 @@ static void ShowProgInfo(CStdOutStream *so)
if (CPU_IsSupported_SHA2()) *so << ",SHA2";
#endif
#endif
*/
*so << endl;
}

View File

@@ -19,8 +19,8 @@ static const UInt32 kLangIDs[] =
IDT_ABOUT_INFO
};
#define kHomePageURL TEXT("http://www.7-zip.org/")
#define kHomePageURL2 TEXT("http://github.com/mcmilk/7-Zip-zstd/")
#define kHomePageURL TEXT("https://www.7-zip.org/")
#define kHomePageURL2 TEXT("https://github.com/mcmilk/7-Zip-zstd/")
#define kHelpTopic "start.htm"
#define LLL_(quote) L##quote

View File

@@ -136,8 +136,11 @@ bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
case kCloseMessage:
{
KillTimer(_timer);
_timer = 0;
if (_timer)
{
KillTimer(kTimerID);
_timer = 0;
}
if (_inCancelMessageBox)
{
_externalCloseMessageWasReceived = true;

View File

@@ -348,7 +348,9 @@ bool CProgressDialog::OnInit()
INIT_AS_UNDEFINED(_processed_Prev);
INIT_AS_UNDEFINED(_packed_Prev);
INIT_AS_UNDEFINED(_ratio_Prev);
_filesStr_Prev.Empty();
_filesTotStr_Prev.Empty();
_foreground = true;
@@ -423,13 +425,14 @@ static const UINT kIDs[] =
IDT_PROGRESS_ELAPSED, IDT_PROGRESS_ELAPSED_VAL,
IDT_PROGRESS_REMAINING, IDT_PROGRESS_REMAINING_VAL,
IDT_PROGRESS_FILES, IDT_PROGRESS_FILES_VAL,
IDT_PROGRESS_RATIO, IDT_PROGRESS_RATIO_VAL,
0, IDT_PROGRESS_FILES_TOTAL,
IDT_PROGRESS_ERRORS, IDT_PROGRESS_ERRORS_VAL,
IDT_PROGRESS_TOTAL, IDT_PROGRESS_TOTAL_VAL,
IDT_PROGRESS_SPEED, IDT_PROGRESS_SPEED_VAL,
IDT_PROGRESS_PROCESSED, IDT_PROGRESS_PROCESSED_VAL,
IDT_PROGRESS_PACKED, IDT_PROGRESS_PACKED_VAL
IDT_PROGRESS_PACKED, IDT_PROGRESS_PACKED_VAL,
IDT_PROGRESS_RATIO, IDT_PROGRESS_RATIO_VAL
};
bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
@@ -546,6 +549,7 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
yPos = my;
x = mx + gSize + padSize;
}
if (kIDs[i] != 0)
MoveItem(kIDs[i], x, yPos, labelSize, sY);
MoveItem(kIDs[i + 1], x + labelSize, yPos, valueSize, sY);
yPos += sStep;
@@ -617,6 +621,7 @@ static void ConvertSizeToString(UInt64 v, wchar_t *s)
s += MyStringLen(s);
*s++ = ' ';
*s++ = c;
*s++ = 'B';
*s++ = 0;
}
}
@@ -829,17 +834,25 @@ void CProgressDialog::UpdateStatInfo(bool showAll)
{
wchar_t s[64];
ConvertUInt64ToString(completedFiles, s);
if (IS_DEFINED_VAL(totalFiles))
{
MyStringCat(s, L" / ");
ConvertUInt64ToString(totalFiles, s + MyStringLen(s));
}
if (_filesStr_Prev != s)
{
_filesStr_Prev = s;
SetItemText(IDT_PROGRESS_FILES_VAL, s);
}
s[0] = 0;
if (IS_DEFINED_VAL(totalFiles))
{
MyStringCopy(s, L" / ");
ConvertUInt64ToString(totalFiles, s + MyStringLen(s));
}
if (_filesTotStr_Prev != s)
{
_filesTotStr_Prev = s;
SetItemText(IDT_PROGRESS_FILES_TOTAL, s);
}
}
const UInt64 packSize = CompressingMode ? outSize : inSize;
@@ -1024,8 +1037,13 @@ bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
case kCloseMessage:
{
KillTimer(_timer);
_timer = 0;
if (_timer)
{
/* 21.03 : KillTimer(kTimerID) instead of KillTimer(_timer).
But (_timer == kTimerID) in Win10. So it worked too */
KillTimer(kTimerID);
_timer = 0;
}
if (_inCancelMessageBox)
{
_externalCloseMessageWasReceived = true;

View File

@@ -169,7 +169,9 @@ class CProgressDialog: public NWindows::NControl::CModalDialog
UInt64 _processed_Prev;
UInt64 _packed_Prev;
UInt64 _ratio_Prev;
UString _filesStr_Prev;
UString _filesTotStr_Prev;
unsigned _prevSpeed_MoveBits;
UInt64 _prevSpeed;

View File

@@ -28,6 +28,7 @@
#define IDT_PROGRESS_PACKED_VAL 110
#define IDT_PROGRESS_FILES_VAL 111
#define IDT_PROGRESS_FILES_TOTAL 112
#define IDT_PROGRESS_ELAPSED_VAL 120
#define IDT_PROGRESS_REMAINING_VAL 121
@@ -41,7 +42,7 @@
#ifdef UNDER_CE
#define MY_PROGRESS_VAL_UNITS 44
#else
#define MY_PROGRESS_VAL_UNITS 76
#define MY_PROGRESS_VAL_UNITS 72
#endif
#define MY_PROGRESS_LABEL_UNITS_MIN 60
#define MY_PROGRESS_LABEL_UNITS_START 90

View File

@@ -47,27 +47,32 @@ CAPTION "Progress"
PUSHBUTTON "&Pause", IDB_PAUSE, bx2, by, bxs, bys
PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys
LTEXT "Elapsed time:", IDT_PROGRESS_ELAPSED, m, y0, x0s, 8
LTEXT "Remaining time:", IDT_PROGRESS_REMAINING, m, y1, x0s, 8
LTEXT "Files:", IDT_PROGRESS_FILES, m, y2, x0s, 8
LTEXT "Compression ratio:", IDT_PROGRESS_RATIO, m, y3, x0s, 8
LTEXT "Errors:", IDT_PROGRESS_ERRORS, m, y4, x0s, 8
LTEXT "Total size:", IDT_PROGRESS_TOTAL, x2, y0, x2s, 8
LTEXT "Speed:", IDT_PROGRESS_SPEED, x2, y1, x2s, 8
LTEXT "Processed:", IDT_PROGRESS_PROCESSED,x2, y2, x2s, 8
LTEXT "Compressed size:" , IDT_PROGRESS_PACKED, x2, y3, x2s, 8
LTEXT "Compression ratio:", IDT_PROGRESS_RATIO, x2, y4, x2s, 8
RTEXT "", IDT_PROGRESS_ELAPSED_VAL, x1, y0, x1s, MY_TEXT_NOPREFIX
RTEXT "", IDT_PROGRESS_REMAINING_VAL, x1, y1, x1s, MY_TEXT_NOPREFIX
RTEXT "", IDT_PROGRESS_FILES_VAL, x1, y2, x1s, MY_TEXT_NOPREFIX
RTEXT "", IDT_PROGRESS_RATIO_VAL, x1, y3, x1s, MY_TEXT_NOPREFIX
RTEXT "", IDT_PROGRESS_FILES_TOTAL x1, y3, x1s, MY_TEXT_NOPREFIX
RTEXT "", IDT_PROGRESS_ERRORS_VAL, x1, y4, x1s, MY_TEXT_NOPREFIX
RTEXT "", IDT_PROGRESS_TOTAL_VAL, x3, y0, x3s, MY_TEXT_NOPREFIX
RTEXT "", IDT_PROGRESS_SPEED_VAL, x3, y1, x3s, MY_TEXT_NOPREFIX
RTEXT "", IDT_PROGRESS_PROCESSED_VAL, x3, y2, x3s, MY_TEXT_NOPREFIX
RTEXT "", IDT_PROGRESS_PACKED_VAL, x3, y3, x3s, MY_TEXT_NOPREFIX
RTEXT "", IDT_PROGRESS_RATIO_VAL, x3, y4, x3s, MY_TEXT_NOPREFIX
LTEXT "", IDT_PROGRESS_STATUS, m, z3, xc, MY_TEXT_NOPREFIX
CONTROL "", IDT_PROGRESS_FILE_NAME, "Static", SS_NOPREFIX | SS_LEFTNOWORDWRAP, m, z2, xc, z2s

View File

File diff suppressed because it is too large Load Diff

View File

@@ -3,190 +3,13 @@
#ifndef __BENCHMARK_DIALOG_H
#define __BENCHMARK_DIALOG_H
#include "../../../Windows/Synchronization.h"
#include "../../Common/CreateCoder.h"
#include "../../UI/Common/Property.h"
#include "../../../Windows/Control/ComboBox.h"
#include "../../../Windows/Control/Edit.h"
#include "../Common/Bench.h"
#include "../FileManager/DialogSize.h"
#include "BenchmarkDialogRes.h"
struct CBenchInfo2 : public CBenchInfo
{
void Init() { GlobalTime = UserTime = 0; }
UInt64 GetCompressRating(UInt32 dictSize) const
{
return ::GetCompressRating(dictSize, GlobalTime, GlobalFreq, UnpackSize * NumIterations);
}
UInt64 GetDecompressRating() const
{
return ::GetDecompressRating(GlobalTime, GlobalFreq, UnpackSize, PackSize, NumIterations);
}
};
class CBenchProgressSync
{
public:
bool Stopped;
bool Paused;
bool Changed;
UInt32 DictionarySize;
UInt32 NumThreads;
UInt64 NumPasses;
NWindows::NSynchronization::CManualResetEvent _startEvent;
NWindows::NSynchronization::CCriticalSection CS;
CBenchInfo2 CompressingInfoTemp;
CBenchInfo2 CompressingInfo;
UInt64 ProcessedSize;
CBenchInfo2 DecompressingInfoTemp;
CBenchInfo2 DecompressingInfo;
AString Text;
bool TextWasChanged;
// bool FirstPath;
// UInt64 Freq;
// UString Freq;
// bool FreqWasChanged;
CBenchProgressSync()
{
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;
// FirstPath = true;
// Freq = 0;
// Freq.SetFromAscii("MHz: ");
// FreqWasChanged = true;
Text.Empty();
TextWasChanged = true;
}
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(); }
};
struct CMyFont
{
HFONT _font;
CMyFont(): _font(NULL) {}
~CMyFont()
{
if (_font)
DeleteObject(_font);
}
void Create(const LOGFONT *lplf)
{
_font = CreateFontIndirect(lplf);
}
};
class CBenchmarkDialog:
public NWindows::NControl::CModalDialog
{
NWindows::NControl::CComboBox m_Dictionary;
NWindows::NControl::CComboBox m_NumThreads;
NWindows::NControl::CEdit _consoleEdit;
UINT_PTR _timer;
UInt32 _startTime;
CMyFont _font;
UInt64 ramSize;
bool ramSize_Defined;
bool OnSize(WPARAM /* wParam */, int xSize, int ySize);
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();
void SetItemText_Number(int itemID, UInt64 val, LPCTSTR post = NULL);
public:
CBenchProgressSync Sync;
bool TotalMode;
CObjectVector<CProperty> Props;
CSysString Bench2Text;
CBenchmarkDialog(): _timer(0), TotalMode(false) {}
INT_PTR Create(HWND wndParent = 0)
{
BIG_DIALOG_SIZE(332, 228);
return CModalDialog::Create(TotalMode ? IDD_BENCH_TOTAL : SIZED_DIALOG(IDD_BENCH), wndParent);
}
void MessageBoxError(LPCWSTR message)
{
MessageBoxW(*this, message, L"7-Zip ZS", MB_ICONERROR);
}
};
const UInt32 k_NumBenchIterations_Default = 10;
HRESULT Benchmark(
DECL_EXTERNAL_CODECS_LOC_VARS
const CObjectVector<CProperty> &props, HWND hwndParent = NULL);
const CObjectVector<CProperty> &props, UInt32 numIterations, HWND hwndParent = NULL);
#endif

View File

@@ -23,25 +23,29 @@
#define g4x (m + m)
#define sRating 60
#define sSpeed 60
#define sUsage 60
#define sRpu 60
#define sFreq 34
#define sRating 58
#define sSpeed 60
#define sUsage 46
#define sRpu 58
#define sSize 52
// #define sFreq 34
#define xRating (xs - m - m - sRating)
#define xRpu (xRating - sRpu)
#define xUsage (xRpu - sUsage)
#define xSpeed (xUsage - sSpeed)
#define xSize (xSpeed - sSize)
#define xFreq (xUsage - sFreq)
// #define xFreq (xUsage - sFreq)
#define sLabel (xUsage - g4x)
#define sLabel (xSize - g4x)
#define sTotalRating (sUsage + sRpu + sRating + m + m)
#define xTotalRating (xs - m - sTotalRating)
#define g2xs 58
#define g3xs 36
#define sPasses 60
#define g2xs 60
#define g3xs 64
#define g3x (m + g2xs)
#undef GROUP_Y_SIZE
@@ -56,7 +60,10 @@
#define g7xs bx1 - m - g0xs - g1xs - m
IDD_BENCH DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX
#define sLog 140 + 0
// MY_MODAL_DIALOG_STYLE
IDD_BENCH DIALOG 0, 0, xs + sLog, ys MY_MODAL_RESIZE_DIALOG_STYLE | WS_MINIMIZEBOX
CAPTION "Benchmark"
MY_FONT
BEGIN
@@ -70,71 +77,79 @@ BEGIN
COMBOBOX IDC_BENCH_DICTIONARY, g1x, m, g1xs, 140, MY_COMBO
LTEXT "Memory usage:", IDT_BENCH_MEMORY, gc2x, m - 2, g7xs, 8
LTEXT "", IDT_BENCH_MEMORY_VAL, gc2x, m + 8, g7xs, 8
LTEXT "", IDT_BENCH_MEMORY_VAL, gc2x, m + 8, g7xs, MY_TEXT_NOPREFIX
LTEXT "&Number of CPU threads:", IDT_BENCH_NUM_THREADS, m, 30, g0xs, 8
COMBOBOX IDC_BENCH_NUM_THREADS, g1x, 29, g1xs, 140, MY_COMBO
LTEXT "", IDT_BENCH_HARDWARE_THREADS, gc2x, 32, g7xs, 8
LTEXT "", IDT_BENCH_HARDWARE_THREADS, gc2x, 30, g7xs, MY_TEXT_NOPREFIX
RTEXT "CPU Usage", IDT_BENCH_USAGE_LABEL, xUsage, 54, sUsage, 8
RTEXT "Speed", IDT_BENCH_SPEED, xSpeed, 54, sSpeed, 8
RTEXT "Rating / Usage", IDT_BENCH_RPU_LABEL, xRpu, 54, sRpu, 8
RTEXT "Rating", IDT_BENCH_RATING_LABEL, xRating, 54, sRating, 8
RTEXT "Size", IDT_BENCH_SIZE, xSize, 54, sSize, MY_TEXT_NOPREFIX
RTEXT "CPU Usage", IDT_BENCH_USAGE_LABEL, xUsage, 54, sUsage, MY_TEXT_NOPREFIX
RTEXT "Speed", IDT_BENCH_SPEED, xSpeed, 54, sSpeed, MY_TEXT_NOPREFIX
RTEXT "Rating / Usage", IDT_BENCH_RPU_LABEL, xRpu, 54, sRpu, MY_TEXT_NOPREFIX
RTEXT "Rating", IDT_BENCH_RATING_LABEL, xRating, 54, sRating, MY_TEXT_NOPREFIX
GROUPBOX "Compressing", IDG_BENCH_COMPRESSING, m, 64, xc, GROUP_Y_SIZE
LTEXT "Current", IDT_BENCH_CURRENT, g4x, 76, sLabel, 8
RTEXT "", IDT_BENCH_COMPRESS_USAGE1, xUsage, 76, sUsage, 8
RTEXT "", IDT_BENCH_COMPRESS_SPEED1, xSpeed, 76, sSpeed, 8
RTEXT "", IDT_BENCH_COMPRESS_RPU1, xRpu, 76, sRpu, 8
RTEXT "", IDT_BENCH_COMPRESS_RATING1, xRating, 76, sRating, 8
LTEXT "Current", IDT_BENCH_CURRENT, g4x, 76, sLabel, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_SIZE1, xSize, 76, sSize, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_USAGE1, xUsage, 76, sUsage, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_SPEED1, xSpeed, 76, sSpeed, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_RPU1, xRpu, 76, sRpu, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_RATING1, xRating, 76, sRating, MY_TEXT_NOPREFIX
LTEXT "Resulting", IDT_BENCH_RESULTING, g4x, 89, sLabel, 8
RTEXT "", IDT_BENCH_COMPRESS_USAGE2, xUsage, 89, sUsage, 8
RTEXT "", IDT_BENCH_COMPRESS_SPEED2, xSpeed, 89, sSpeed, 8
RTEXT "", IDT_BENCH_COMPRESS_RPU2, xRpu, 89, sRpu, 8
RTEXT "", IDT_BENCH_COMPRESS_RATING2, xRating, 89, sRating, 8
LTEXT "Resulting", IDT_BENCH_RESULTING, g4x, 89, sLabel, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_SIZE2, xSize, 89, sSize, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_USAGE2, xUsage, 89, sUsage, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_SPEED2, xSpeed, 89, sSpeed, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_RPU2, xRpu, 89, sRpu, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_RATING2, xRating, 89, sRating, MY_TEXT_NOPREFIX
GROUPBOX "Decompressing", IDG_BENCH_DECOMPRESSING, m, 111, xc, GROUP_Y_SIZE
LTEXT "Current", IDT_BENCH_CURRENT2, g4x, 123, sLabel, 8
RTEXT "", IDT_BENCH_DECOMPR_USAGE1, xUsage, 123, sUsage, 8
RTEXT "", IDT_BENCH_DECOMPR_SPEED1, xSpeed, 123, sSpeed, 8
RTEXT "", IDT_BENCH_DECOMPR_RPU1, xRpu, 123, sRpu, 8
RTEXT "", IDT_BENCH_DECOMPR_RATING1, xRating, 123, sRating, 8
LTEXT "Current", IDT_BENCH_CURRENT2, g4x, 123, sLabel, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_SIZE1, xSize, 123, sSize, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_USAGE1, xUsage, 123, sUsage, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_SPEED1, xSpeed, 123, sSpeed, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_RPU1, xRpu, 123, sRpu, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_RATING1, xRating, 123, sRating, MY_TEXT_NOPREFIX
LTEXT "Resulting", IDT_BENCH_RESULTING2, g4x, 136, sLabel, 8
RTEXT "", IDT_BENCH_DECOMPR_USAGE2, xUsage, 136, sUsage, 8
RTEXT "", IDT_BENCH_DECOMPR_SPEED2, xSpeed, 136, sSpeed, 8
RTEXT "", IDT_BENCH_DECOMPR_RPU2, xRpu, 136, sRpu, 8
RTEXT "", IDT_BENCH_DECOMPR_RATING2, xRating, 136, sRating, 8
LTEXT "Resulting", IDT_BENCH_RESULTING2, g4x, 136, sLabel, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_SIZE2, xSize, 136, sSize, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_USAGE2, xUsage, 136, sUsage, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_SPEED2, xSpeed, 136, sSpeed, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_RPU2, xRpu, 136, sRpu, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_RATING2, xRating, 136, sRating, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_ERROR_MESSAGE, m, 155, xc, MY_TEXT_NOPREFIX
GROUPBOX "Total Rating", IDG_BENCH_TOTAL_RATING, xTotalRating, 163, sTotalRating, GROUP_Y2_SIZE
RTEXT "", IDT_BENCH_TOTAL_USAGE_VAL, xUsage, 176, sUsage, 8
RTEXT "", IDT_BENCH_TOTAL_RPU_VAL, xRpu, 176, sRpu, 8
RTEXT "", IDT_BENCH_TOTAL_RATING_VAL, xRating, 176, sRating, 8
RTEXT "", IDT_BENCH_TOTAL_USAGE_VAL, xUsage, 176, sUsage, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_TOTAL_RPU_VAL, xRpu, 176, sRpu, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_TOTAL_RATING_VAL, xRating, 176, sRating, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_CPU, m, 202, xc, 8
RTEXT "", IDT_BENCH_VER, m + xc - 100, 216, 100, 8
// RTEXT "", IDT_BENCH_CPU, m + sPasses, 202, xc - sPasses, 16, SS_NOPREFIX
RTEXT "", IDT_BENCH_CPU, m + 0, 202, xc - 0, 16, SS_NOPREFIX
RTEXT "", IDT_BENCH_VER, m + xc - 100, 222, 100, MY_TEXT_NOPREFIX
LTEXT "", IDT_BENCH_CPU_FEATURE, m, 228, xc - 100, 8
LTEXT "", IDT_BENCH_SYS1, m, 238, xc - 140, 8
LTEXT "", IDT_BENCH_SYS2, m, 248, xc - 140, 8
// LTEXT "", IDT_BENCH_SYSTEM, m, 232, xc - 80, 8
// LTEXT "", IDT_BENCH_FREQ_RES, m, 242, 80, 8
LTEXT "", IDT_BENCH_CPU_FEATURE, m, 222, xc - 100, 16, SS_NOPREFIX // - 100
LTEXT "", IDT_BENCH_SYS1, m, 238, xc - 140, MY_TEXT_NOPREFIX
LTEXT "", IDT_BENCH_SYS2, m, 248, xc - 140, MY_TEXT_NOPREFIX
LTEXT "", IDT_BENCH_LOG, m + xc + m, m, sLog - m, yc, SS_LEFTNOWORDWRAP | SS_NOPREFIX
LTEXT "Elapsed time:", IDT_BENCH_ELAPSED, m, 163, g2xs, 8
LTEXT "Size:", IDT_BENCH_SIZE, m, 176, g2xs, 8
LTEXT "Passes:", IDT_BENCH_PASSES, m, 189, g2xs, 8
// LTEXT "Size:", IDT_BENCH_SIZE, m, 176, g2xs, 8
LTEXT "Passes:", IDT_BENCH_PASSES, m, 176, g2xs, 8
COMBOBOX IDC_BENCH_NUM_PASSES, m, 187, sPasses, 140, MY_COMBO
RTEXT "", IDT_BENCH_ELAPSED_VAL, g3x, 163, g3xs, MY_TEXT_NOPREFIX
// RTEXT "", IDT_BENCH_SIZE_VAL, g3x, 176, g3xs, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_PASSES_VAL, g3x, 176, g3xs, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_ELAPSED_VAL, g3x, 163, g3xs, 8
RTEXT "", IDT_BENCH_SIZE_VAL, g3x, 176, g3xs, 8
RTEXT "", IDT_BENCH_PASSES_VAL, g3x, 189, g3xs, 8
END
#ifdef UNDER_CE

View File

@@ -38,9 +38,17 @@
#define IDT_BENCH_TOTAL_USAGE_VAL 133
#define IDT_BENCH_ELAPSED_VAL 140
#define IDT_BENCH_SIZE_VAL 141
// #define IDT_BENCH_SIZE_VAL 141
#define IDT_BENCH_PASSES_VAL 142
#define IDC_BENCH_NUM_PASSES 143
#define IDT_BENCH_LOG 160
#define IDT_BENCH_ERROR_MESSAGE 161
#define IDT_BENCH_COMPRESS_SIZE1 170
#define IDT_BENCH_COMPRESS_SIZE2 171
#define IDT_BENCH_DECOMPR_SIZE1 172
#define IDT_BENCH_DECOMPR_SIZE2 173
// #define IDT_BENCH_FREQ_CUR 150
// #define IDT_BENCH_FREQ_RES 151

View File

@@ -83,6 +83,8 @@ static const unsigned kHistorySize = 20;
static const UInt32 kNoSolidBlockSize = 0;
static const UInt32 kSolidBlockSize = 64;
static const UInt32 kLzmaMaxDictSize = (UInt32)15 << 28;
static LPCSTR const kExeExt = ".exe";
#define k7zFormat "7z"
@@ -375,18 +377,20 @@ static bool IsMethodSupportedBySfx(int methodID)
return false;
}
static bool GetMaxRamSizeForProgram(UInt64 &physSize)
static bool GetMaxRamSizeForProgram(UInt64 &ramSize, UInt64 &size)
{
physSize = (UInt64)(sizeof(size_t)) << 29;
bool ramSize_Defined = NSystem::GetRamSize(physSize);
size = (UInt64)(sizeof(size_t)) << 29;
bool ramSize_Defined = NSystem::GetRamSize(size);
ramSize = size;
size = size / 16 * 15;
const UInt64 kMinSysSize = (1 << 24);
if (physSize <= kMinSysSize)
physSize = 0;
if (size <= kMinSysSize)
size = 0;
else
physSize -= kMinSysSize;
size -= kMinSysSize;
const UInt64 kMinUseSize = (1 << 24);
if (physSize < kMinUseSize)
physSize = kMinUseSize;
if (size < kMinUseSize)
size = kMinUseSize;
return ramSize_Defined;
}
@@ -535,7 +539,7 @@ bool CCompressDialog::OnInit()
SetSolidBlockSize();
SetNumThreads();
TCHAR s[40] = { TEXT('/'), TEXT(' '), 0 };
TCHAR s[32] = { TEXT('/'), TEXT(' '), 0 };
ConvertUInt32ToString(NSystem::GetNumberOfProcessors(), s + 2);
SetItemText(IDT_COMPRESS_HARDWARE_THREADS, s);
@@ -780,6 +784,48 @@ static bool IsAsciiString(const UString &s)
return true;
}
static void AddSize_MB(UString &s, UInt64 size)
{
char temp[32];
ConvertUInt64ToString((size + (1 << 20) - 1) >> 20, temp);
s += temp;
s += " MB";
}
void SetErrorMessage_MemUsage(UString &s, UInt64 reqSize, UInt64 ramSize, UInt64 ramLimit, const UString &usageString)
{
s += "The operation was blocked by 7-Zip";
s.Add_LF();
s += "The operation can require big amount of RAM (memory):";
s.Add_LF();
s.Add_LF();
AddSize_MB(s, reqSize);
if (!usageString.IsEmpty())
{
s += " : ";
s += usageString;
}
s.Add_LF();
AddSize_MB(s, ramSize);
s += " : RAM";
if (ramLimit != 0)
{
s.Add_LF();
AddSize_MB(s, ramLimit);
s += " : 7-Zip limit";
}
s.Add_LF();
s.Add_LF();
s += LangString(IDS_MEM_ERROR);
}
void CCompressDialog::OnOK()
{
_password1Control.GetText(Info.Password);
@@ -811,6 +857,24 @@ void CCompressDialog::OnOK()
}
}
{
UInt64 ramSize;
UInt64 maxRamSize;
const bool maxRamSize_Defined = GetMaxRamSizeForProgram(ramSize, maxRamSize);
UInt64 decompressMem;
const UInt64 memUsage = GetMemoryUsage_DecompMem(decompressMem);
if (maxRamSize_Defined && memUsage > maxRamSize)
{
UString s;
UString s2 = LangString(IDT_COMPRESS_MEMORY);
if (s2.IsEmpty())
GetItemText(IDT_COMPRESS_MEMORY, s2);
SetErrorMessage_MemUsage(s, memUsage, ramSize, maxRamSize, s2);
MessageBoxError(s);
return;
}
}
SaveOptionsInMem();
{
UString s;
@@ -829,7 +893,7 @@ void CCompressDialog::OnOK()
Info.PathMode = (NWildcard::ECensorPathMode)k_PathMode_Vals[m_PathMode.GetCurSel()];
Info.Level = GetLevelSpec();
Info.Dictionary = GetDictionarySpec();
Info.Dict64 = GetDictSpec();
Info.Order = GetOrderSpec();
Info.OrderMode = GetOrderMode();
Info.NumThreads = GetNumThreadsSpec();
@@ -1372,22 +1436,28 @@ UString CCompressDialog::GetEncryptionMethodSpec()
return s;
}
void CCompressDialog::AddDictionarySize(UInt32 size)
void CCompressDialog::AddDict2(size_t sizeReal, size_t sizeShow)
{
Byte c = 0;
unsigned moveBits = 0;
if ((size & 0xFFFFF) == 0) { moveBits = 20; c = 'M'; }
else if ((size & 0x3FF) == 0) { moveBits = 10; c = 'K'; }
TCHAR s[40];
ConvertUInt32ToString(size >> moveBits, s);
if ((sizeShow & 0xFFFFF) == 0) { moveBits = 20; c = 'M'; }
else if ((sizeShow & 0x3FF) == 0) { moveBits = 10; c = 'K'; }
TCHAR s[32];
ConvertUInt64ToString(sizeShow >> moveBits, s);
unsigned pos = MyStringLen(s);
s[pos++] = ' ';
if (moveBits != 0)
s[pos++] = c;
s[pos++] = 'B';
s[pos++] = 0;
int index = (int)m_Dictionary.AddString(s);
m_Dictionary.SetItemData(index, size);
const int index = (int)m_Dictionary.AddString(s);
m_Dictionary.SetItemData(index, sizeReal);
}
void CCompressDialog::AddDict(size_t size)
{
AddDict2(size, size);
}
typedef enum {
@@ -1435,7 +1505,7 @@ void CCompressDialog::SetDictionary()
{
m_Dictionary.ResetContent();
const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
int index = FindRegistryFormat(ai.Name);
const int index = FindRegistryFormat(ai.Name);
UInt32 defaultDict = (UInt32)(Int32)-1;
if (index >= 0)
@@ -1445,12 +1515,13 @@ void CCompressDialog::SetDictionary()
defaultDict = fo.Dictionary;
}
int methodID = GetMethodID();
const int methodID = GetMethodID();
UInt32 level = GetLevel2();
if (methodID < 0)
return;
UInt64 ramSize;
UInt64 maxRamSize;
bool maxRamSize_Defined = GetMaxRamSizeForProgram(maxRamSize);
const bool maxRamSize_Defined = GetMaxRamSizeForProgram(ramSize, maxRamSize);
switch (methodID)
{
@@ -1460,38 +1531,44 @@ void CCompressDialog::SetDictionary()
if (defaultDict == (UInt32)(Int32)-1)
{
defaultDict =
( level <= 3 ? (1 << (level * 2 + 16)) :
( level <= 6 ? (1 << (level + 19)) :
( level <= 7 ? (1 << 25) : (1 << 26)
)));
( level <= 3 ? ((UInt32)1 << (level * 2 + 16)) :
( level <= 6 ? ((UInt32)1 << (level + 19)) :
( level <= 7 ? ((UInt32)1 << 25) : ((UInt32)1 << 26)
)));
}
AddDictionarySize(1 << 16);
AddDictionarySize(1 << 18);
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
for (unsigned i = 20; i <= 31; i++)
for (unsigned j = 0; j < 2; j++)
{
if (i == 20 && j > 0)
continue;
UInt32 dict = ((UInt32)(2 + j) << (i - 1));
if (dict >
#ifdef MY_CPU_64BIT
(3 << 29)
#else
(1 << 26)
#endif
)
continue;
AddDictionarySize(dict);
UInt64 decomprSize;
UInt64 requiredComprSize = GetMemoryUsage(dict, decomprSize);
if (dict <= defaultDict && (!maxRamSize_Defined || requiredComprSize <= maxRamSize))
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
}
// we use threshold 3.75 GiB to switch to kLzmaMaxDictSize.
if (defaultDict >= ((UInt32)15 << 28))
defaultDict = kLzmaMaxDictSize;
const size_t kLzmaMaxDictSize_Up = (size_t)1 << (20 + sizeof(size_t) / 4 * 6);
int curSel = 0;
for (unsigned i = (16 - 1) * 2; i <= (32 - 1) * 2; i++)
{
if (i < (20 - 1) * 2
&& i != (16 - 1) * 2
&& i != (18 - 1) * 2)
continue;
if (i == (20 - 1) * 2 + 1)
continue;
const size_t dict_up = (size_t)(2 + (i & 1)) << (i / 2);
size_t dict = dict_up;
if (dict_up >= kLzmaMaxDictSize)
dict = kLzmaMaxDictSize; // we reduce dictionary
AddDict(dict);
// AddDict2(dict, dict_up); // for debug : we show 4 GB
const UInt64 memUsage = GetMemoryUsageComp_Dict(dict);
if (dict <= defaultDict && (!maxRamSize_Defined || memUsage <= maxRamSize))
curSel = m_Dictionary.GetCount() - 1;
if (dict_up >= kLzmaMaxDictSize_Up)
break;
}
m_Dictionary.SetCurSel(curSel);
// SetNearestSelectComboBox(m_Dictionary, defaultDict);
break;
}
@@ -1519,10 +1596,9 @@ void CCompressDialog::SetDictionary()
)
continue;
AddDictionarySize(dict);
UInt64 decomprSize;
UInt64 requiredComprSize = GetMemoryUsage(dict, decomprSize);
if (dict <= defaultDict && (!maxRamSize_Defined || requiredComprSize <= maxRamSize))
AddDict(dict);
const UInt64 memUsage = GetMemoryUsageComp_Dict(dict);
if (dict <= defaultDict && (!maxRamSize_Defined || memUsage <= maxRamSize))
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
}
@@ -1532,46 +1608,63 @@ void CCompressDialog::SetDictionary()
case kPPMd:
{
if (defaultDict == (UInt32)(Int32)-1)
{
defaultDict = (UInt32)1 << (level + 19);
}
for (unsigned i = 20; i < 31; i++)
for (unsigned j = 0; j < 2; j++)
{
if (i == 20 && j > 0)
continue;
UInt32 dict = ((UInt32)(2 + j) << (i - 1));
if (dict >
#ifdef MY_CPU_64BIT
(1 << 30)
#else
(1 << 29)
#endif
)
continue;
AddDictionarySize(dict);
UInt64 decomprSize;
UInt64 requiredComprSize = GetMemoryUsage(dict, decomprSize);
if ((dict <= defaultDict && (!maxRamSize_Defined || requiredComprSize <= maxRamSize))
|| m_Dictionary.GetCount() == 1)
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
}
const UInt32 kPpmd_Default_4g = (UInt32)0 - ((UInt32)1 << 10);
const size_t kPpmd_MaxDictSize_Up = (size_t)1 << (29 + sizeof(size_t) / 8);
if (defaultDict >= ((UInt32)15 << 28)) // threshold
defaultDict = kPpmd_Default_4g;
int curSel = 0;
for (unsigned i = (20 - 1) * 2; i <= (32 - 1) * 2; i++)
{
if (i == (20 - 1) * 2 + 1)
continue;
const size_t dict_up = (size_t)(2 + (i & 1)) << (i / 2);
size_t dict = dict_up;
if (dict_up >= kPpmd_Default_4g)
dict = kPpmd_Default_4g;
AddDict2(dict, dict_up);
// AddDict2((UInt32)((UInt32)0 - 2), dict_up); // for debug
// AddDict(dict_up); // for debug
const UInt64 memUsage = GetMemoryUsageComp_Dict(dict);
if (dict <= defaultDict && (!maxRamSize_Defined || memUsage <= maxRamSize))
curSel = m_Dictionary.GetCount() - 1;
if (dict_up >= kPpmd_MaxDictSize_Up)
break;
}
m_Dictionary.SetCurSel(curSel);
// SetNearestSelectComboBox(m_Dictionary, defaultDict);
break;
}
case kPPMdZip:
{
if (defaultDict == (UInt32)(Int32)-1)
defaultDict = (UInt32)1 << (level + 19);
int curSel = 0;
for (unsigned i = 20; i <= 28; i++)
{
const UInt32 dict = (UInt32)1 << i;
AddDict(dict);
const UInt64 memUsage = GetMemoryUsageComp_Dict(dict);
if ((dict <= defaultDict && (!maxRamSize_Defined || memUsage <= maxRamSize)))
curSel = m_Dictionary.GetCount() - 1;
}
m_Dictionary.SetCurSel(curSel);
// SetNearestSelectComboBox(m_Dictionary, defaultDict);
break;
}
case kDeflate:
{
AddDictionarySize(32 << 10);
m_Dictionary.SetCurSel(0);
break;
}
case kDeflate64:
{
AddDictionarySize(64 << 10);
const UInt32 dict = (methodID == kDeflate ? (UInt32)(1 << 15) : (UInt32)(1 << 16));
AddDict(dict);
m_Dictionary.SetCurSel(0);
break;
}
@@ -1585,39 +1678,22 @@ void CCompressDialog::SetDictionary()
else defaultDict = (100 << 10);
}
int curSel = 0;
for (unsigned i = 1; i <= 9; i++)
{
UInt32 dict = ((UInt32)i * 100) << 10;
AddDictionarySize(dict);
if (dict <= defaultDict || m_Dictionary.GetCount() == 0)
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
const UInt32 dict = ((UInt32)i * 100) << 10;
AddDict(dict);
// AddDict2(i * 100000, dict);
if (i <= defaultDict / 100000)
curSel = m_Dictionary.GetCount() - 1;
}
break;
}
case kPPMdZip:
{
if (defaultDict == (UInt32)(Int32)-1)
defaultDict = (UInt32)1 << (level + 19);
for (unsigned i = 20; i <= 28; i++)
{
UInt32 dict = (1 << i);
AddDictionarySize(dict);
UInt64 decomprSize;
UInt64 requiredComprSize = GetMemoryUsage(dict, decomprSize);
if ((dict <= defaultDict && (!maxRamSize_Defined || requiredComprSize <= maxRamSize))
|| m_Dictionary.GetCount() == 1)
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
}
// SetNearestSelectComboBox(m_Dictionary, defaultDict);
m_Dictionary.SetCurSel(curSel);
break;
}
}
}
UInt32 CCompressDialog::GetComboValue(NWindows::NControl::CComboBox &c, int defMax)
{
if (c.GetCount() <= defMax)
@@ -1625,6 +1701,15 @@ UInt32 CCompressDialog::GetComboValue(NWindows::NControl::CComboBox &c, int defM
return (UInt32)c.GetItemData_of_CurSel();
}
UInt64 CCompressDialog::GetComboValue_64(NWindows::NControl::CComboBox &c, int defMax)
{
if (c.GetCount() <= defMax)
return (UInt64)(Int64)-1;
// LRESULT is signed. so we cast it to unsigned size_t at first:
return (UInt64)(size_t)c.GetItemData_of_CurSel();
}
UInt32 CCompressDialog::GetLevel2()
{
UInt32 level = GetLevel();
@@ -1635,7 +1720,7 @@ UInt32 CCompressDialog::GetLevel2()
int CCompressDialog::AddOrder(UInt32 size)
{
TCHAR s[40];
TCHAR s[32];
ConvertUInt32ToString(size, s);
int index = (int)m_Order.AddString(s);
m_Order.SetItemData(index, size);
@@ -1761,7 +1846,7 @@ bool CCompressDialog::GetOrderMode()
}
static UInt64 Get_Lzma2_ChunkSize(UInt32 dict)
static UInt64 Get_Lzma2_ChunkSize(UInt64 dict)
{
// we use same default chunk sizes as defined in 7z encoder and lzma2 encoder
UInt64 cs = (UInt64)dict << 2;
@@ -1787,8 +1872,8 @@ void CCompressDialog::SetSolidBlockSize(bool useDictionary)
if (level == 0)
return;
UInt32 dict = GetDictionarySpec();
if (dict == (UInt32)(Int32)-1)
UInt64 dict = GetDictSpec();
if (dict == (UInt64)(Int64)-1)
dict = 1;
UInt32 defaultBlockSize = (UInt32)(Int32)-1;
@@ -1847,7 +1932,7 @@ void CCompressDialog::SetSolidBlockSize(bool useDictionary)
if (defaultBlockSize == (UInt32)(Int32)-1 && ((UInt64)1 << i) >= blockSize)
defaultBlockSize = i;
TCHAR s[40];
TCHAR s[32];
char post;
ConvertUInt32ToString(1 << (i % 10), s);
if (i < 20) post = 'K';
@@ -1918,7 +2003,7 @@ void CCompressDialog::SetNumThreads()
numAlgoThreadsMax = 128;
for (UInt32 i = 1; i <= numHardwareThreads * 2 && i <= numAlgoThreadsMax; i++)
{
TCHAR s[40];
TCHAR s[32];
ConvertUInt32ToString(i, s);
int index = (int)m_NumThreads.AddString(s);
m_NumThreads.SetItemData(index, (UInt32)i);
@@ -1926,7 +2011,8 @@ void CCompressDialog::SetNumThreads()
SetNearestSelectComboBox(m_NumThreads, defaultValue);
}
UInt64 CCompressDialog::GetMemoryUsage(UInt32 dict, UInt64 &decompressMemory)
UInt64 CCompressDialog::GetMemoryUsage_Dict_DecompMem(UInt64 dict64, UInt64 &decompressMemory)
{
decompressMemory = UInt64(Int64(-1));
UInt32 level = GetLevel2();
@@ -1959,6 +2045,7 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dict, UInt64 &decompressMemory)
case kLZMA:
case kLZMA2:
{
const UInt32 dict = (dict64 >= kLzmaMaxDictSize ? kLzmaMaxDictSize : (UInt32)dict64);
UInt32 hs = dict - 1;
hs |= (hs >> 1);
hs |= (hs >> 2);
@@ -2010,7 +2097,15 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dict, UInt64 &decompressMemory)
}
if (chunkSize == 0)
size += numBlockThreads * (size1 + (UInt64)dict * 3 / 2);
{
const UInt32 kBlockSizeMax = (UInt32)0 - (UInt32)(1 << 16);
UInt64 blockSize = (UInt64)dict + (1 << 16)
+ (numThreads1 > 1 ? (1 << 20) : 0);
blockSize += (blockSize >> (blockSize < ((UInt32)1 << 30) ? 1 : 2));
if (blockSize >= kBlockSizeMax)
blockSize = kBlockSizeMax;
size += numBlockThreads * (size1 + blockSize);
}
else
{
size += numBlockThreads * (size1 + chunkSize);
@@ -2024,6 +2119,7 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dict, UInt64 &decompressMemory)
case kFLZMA2:
{
const UInt32 dict = (dict64 >= kLzmaMaxDictSize ? kLzmaMaxDictSize : (UInt32)dict64);
if (level > FL2_MAX_7Z_CLEVEL)
level = FL2_MAX_7Z_CLEVEL;
/* dual buffer is enabled in Lzma2Encoder.cpp so size is dict * 6 */
@@ -2049,7 +2145,7 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dict, UInt64 &decompressMemory)
case kPPMd:
{
decompressMemory = dict + (2 << 20);
decompressMemory = dict64 + (2 << 20);
return size + decompressMemory;
}
@@ -2077,7 +2173,7 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dict, UInt64 &decompressMemory)
case kPPMdZip:
{
decompressMemory = dict + (2 << 20);
decompressMemory = dict64 + (2 << 20);
return size + (UInt64)decompressMemory * numThreads;
}
}
@@ -2085,9 +2181,15 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dict, UInt64 &decompressMemory)
return (UInt64)(Int64)-1;
}
UInt64 CCompressDialog::GetMemoryUsage(UInt64 &decompressMemory)
UInt64 CCompressDialog::GetMemoryUsage_DecompMem(UInt64 &decompressMemory)
{
return GetMemoryUsage(GetDictionary(), decompressMemory);
return GetMemoryUsage_Dict_DecompMem(GetDict(), decompressMemory);
}
UInt64 CCompressDialog::GetMemoryUsageComp_Dict(UInt64 dict64)
{
UInt64 decompressMemory;
return GetMemoryUsage_Dict_DecompMem(dict64, decompressMemory);
}
void CCompressDialog::PrintMemUsage(UINT res, UInt64 value)
@@ -2097,7 +2199,7 @@ void CCompressDialog::PrintMemUsage(UINT res, UInt64 value)
SetItemText(res, TEXT("?"));
return;
}
TCHAR s[40];
TCHAR s[32];
if (value <= ((UInt64)16 << 30))
{
value = (value + (1 << 20) - 1) >> 20;
@@ -2116,7 +2218,7 @@ void CCompressDialog::PrintMemUsage(UINT res, UInt64 value)
void CCompressDialog::SetMemoryUsage()
{
UInt64 decompressMem;
UInt64 memUsage = GetMemoryUsage(decompressMem);
const UInt64 memUsage = GetMemoryUsage_DecompMem(decompressMem);
PrintMemUsage(IDT_COMPRESS_MEMORY_VALUE, memUsage);
PrintMemUsage(IDT_COMPRESS_MEMORY_DE_VALUE, decompressMem);
}
@@ -2125,7 +2227,7 @@ void CCompressDialog::SetParams()
{
const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
m_Params.SetText(TEXT(""));
int index = FindRegistryFormat(ai.Name);
const int index = FindRegistryFormat(ai.Name);
if (index >= 0)
{
const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
@@ -2137,7 +2239,7 @@ void CCompressDialog::SetParams()
void CCompressDialog::SaveOptionsInMem()
{
const CArcInfoEx &ai = (*ArcFormats)[Info.FormatIndex];
int index = FindRegistryFormatAlways(ai.Name);
const int index = FindRegistryFormatAlways(ai.Name);
m_Params.GetText(Info.Options);
m_Volume.GetText(Info.SplitVolume);
Info.Options.Trim();
@@ -2146,12 +2248,32 @@ void CCompressDialog::SaveOptionsInMem()
fo.Options = Info.Options;
fo.SplitVolume = Info.SplitVolume;
fo.Level = GetLevelSpec();
fo.Dictionary = GetDictionarySpec();
fo.Order = GetOrderSpec();
fo.Method = GetMethodSpec();
fo.EncryptionMethod = GetEncryptionMethodSpec();
fo.NumThreads = GetNumThreadsSpec();
fo.BlockLogSize = GetBlockSizeSpec();
{
const UInt64 dict64 = GetDictSpec();
UInt32 dict32;
if (dict64 == (UInt64)(Int64)-1)
dict32 = (UInt32)(Int32)-1;
else
{
dict32 = (UInt32)dict64;
if (dict64 != dict32)
{
/* here we must write 32-bit value for registry that indicates big_value
(UInt32)(Int32)-1 : is used as marker for default size
(UInt32)(Int32)-2 : it can be used to indicate big value (4 GiB)
the value must be larger than threshold
*/
dict32 = (UInt32)(Int32)-2;
// dict32 = kLzmaMaxDictSize; // it must be larger than threshold
}
}
fo.Dictionary = dict32;
}
}
unsigned CCompressDialog::GetFormatIndex()

View File

@@ -42,7 +42,7 @@ namespace NCompressDialog
UInt32 Level;
UString Method;
UInt32 Dictionary;
UInt64 Dict64;
bool OrderMode;
UInt32 Order;
UString Options;
@@ -80,7 +80,8 @@ namespace NCompressDialog
DeleteAfterCompressing(false),
FormatIndex(-1)
{
Level = Dictionary = Order = UInt32(-1);
Level = Order = (UInt32)(Int32)-1;
Dict64 = (UInt64)(Int64)(-1);
OrderMode = false;
Method.Empty();
Options.Empty();
@@ -90,6 +91,7 @@ namespace NCompressDialog
};
}
class CCompressDialog: public NWindows::NControl::CModalDialog
{
NWindows::NControl::CComboBox m_ArchivePath;
@@ -144,17 +146,19 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
void SetEncryptionMethod();
void AddDictionarySize(UInt32 size);
void AddDict2(size_t sizeReal, size_t sizeShow);
void AddDict(size_t size);
void SetDictionary();
UInt32 GetComboValue(NWindows::NControl::CComboBox &c, int defMax = 0);
UInt64 GetComboValue_64(NWindows::NControl::CComboBox &c, int defMax = 0);
UInt32 GetLevel() { return GetComboValue(m_Level); }
UInt32 GetLevelSpec() { return GetComboValue(m_Level, 1); }
UInt32 GetLevel2();
UInt32 GetDictionary() { return GetComboValue(m_Dictionary); }
UInt32 GetDictionarySpec() { return GetComboValue(m_Dictionary, 1); }
UInt64 GetDict() { return GetComboValue_64(m_Dictionary); }
UInt64 GetDictSpec() { return GetComboValue_64(m_Dictionary, 1); }
UInt32 GetOrder() { return GetComboValue(m_Order); }
UInt32 GetOrderSpec() { return GetComboValue(m_Order, 1); }
UInt32 GetNumThreadsSpec() { return GetComboValue(m_NumThreads, 1); }
@@ -168,8 +172,10 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
void SetSolidBlockSize(bool useDictionary = false);
void SetNumThreads();
UInt64 GetMemoryUsage(UInt32 dict, UInt64 &decompressMemory);
UInt64 GetMemoryUsage(UInt64 &decompressMemory);
UInt64 GetMemoryUsage_Dict_DecompMem(UInt64 dict, UInt64 &decompressMemory);
UInt64 GetMemoryUsage_DecompMem(UInt64 &decompressMemory);
UInt64 GetMemoryUsageComp_Dict(UInt64 dict64);
void PrintMemUsage(UINT res, UInt64 value);
void SetMemoryUsage();
void SetParams();
@@ -198,6 +204,11 @@ public:
CCompressDialog(): CurrentDirWasChanged(false) {};
void MessageBoxError(LPCWSTR message)
{
MessageBoxW(*this, message, L"7-Zip", MB_ICONERROR);
}
protected:
void CheckSFXControlsEnable();

View File

@@ -193,7 +193,12 @@ static int Main2()
if (options.Command.CommandType == NCommandType::kBenchmark)
{
HRESULT res = Benchmark(EXTERNAL_CODECS_VARS_L options.Properties);
HRESULT res = Benchmark(
EXTERNAL_CODECS_VARS_L
options.Properties,
options.NumIterations_Defined ?
options.NumIterations :
k_NumBenchIterations_Default);
/*
if (res == S_FALSE)
{

View File

@@ -1164,6 +1164,10 @@ SOURCE=..\..\..\Windows\SystemInfo.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\Thread.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\TimeUtils.cpp
# End Source File
# Begin Source File

View File

@@ -142,7 +142,7 @@ static void SetOutProperties(
UInt32 level,
bool setMethod,
const UString &method,
UInt32 dictionary,
UInt64 dict64,
bool orderMode,
UInt32 order,
bool solidIsSpecified, UInt64 solidBlockSize,
@@ -157,13 +157,13 @@ static void SetOutProperties(
{
if (!method.IsEmpty())
AddProp(properties, is7z ? "0": "m", method);
if (dictionary != (UInt32)(Int32)-1)
if (dict64 != (UInt64)(Int64)-1)
{
AString name;
if (is7z)
name = "0";
name += (orderMode ? "mem" : "d");
AddProp(properties, name, GetNumInBytesString(dictionary));
AddProp(properties, name, GetNumInBytesString(dict64));
}
if (order != (UInt32)(Int32)-1)
{
@@ -389,7 +389,7 @@ static HRESULT ShowDialog(
di.Level,
!methodOverride,
di.Method,
di.Dictionary,
di.Dict64,
di.OrderMode, di.Order,
di.SolidIsSpecified, di.SolidBlockSize,
di.MultiThreadIsAllowed, di.NumThreads,