mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-07 20:06:59 -06:00
4.45 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
d9666cf046
commit
a145bfc7cf
@@ -44,7 +44,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /FAcs /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -69,7 +69,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -94,7 +94,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\\" /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_CONSOLE" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\\" /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -121,7 +121,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -227,20 +227,24 @@ SOURCE=..\..\..\Windows\FileIO.cpp
|
||||
|
||||
SOURCE=..\..\..\Windows\FileIO.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Synchronization.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Synchronization.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Thread.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\CommandLineParser.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -253,10 +257,6 @@ SOURCE=..\..\..\Common\CRC.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\CRC.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Defs.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -367,6 +367,24 @@ SOURCE=..\..\..\..\C\Compress\Lz\MatchFinder.c
|
||||
|
||||
SOURCE=..\..\..\..\C\Compress\Lz\MatchFinder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Compress\Lz\MatchFinderMt.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Compress\Lz\MatchFinderMt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Threads.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Threads.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "LZMA_C"
|
||||
|
||||
@@ -411,6 +429,19 @@ SOURCE=..\..\..\..\C\7zCrc.c
|
||||
|
||||
SOURCE=..\..\..\..\C\7zCrc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Alloc.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Types.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
@@ -430,6 +461,14 @@ SOURCE=.\LzmaBench.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LzmaBenchCon.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LzmaBenchCon.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LzmaRam.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -25,9 +25,13 @@
|
||||
#include "../LZMA/LZMADecoder.h"
|
||||
#include "../LZMA/LZMAEncoder.h"
|
||||
|
||||
#include "LzmaBench.h"
|
||||
#include "LzmaBenchCon.h"
|
||||
#include "LzmaRam.h"
|
||||
|
||||
#ifdef COMPRESS_MF_MT
|
||||
#include "Windows/System.h"
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "LzmaRamDecode.h"
|
||||
@@ -64,6 +68,7 @@ enum Enum
|
||||
kLitPos,
|
||||
kPosBits,
|
||||
kMatchFinder,
|
||||
kMultiThread,
|
||||
kEOS,
|
||||
kStdIn,
|
||||
kStdOut,
|
||||
@@ -83,6 +88,7 @@ static const CSwitchForm kSwitchForms[] =
|
||||
{ L"LP", NSwitchType::kUnLimitedPostString, false, 1 },
|
||||
{ L"PB", NSwitchType::kUnLimitedPostString, false, 1 },
|
||||
{ L"MF", NSwitchType::kUnLimitedPostString, false, 1 },
|
||||
{ L"MT", NSwitchType::kUnLimitedPostString, false, 0 },
|
||||
{ L"EOS", NSwitchType::kSimple, false },
|
||||
{ L"SI", NSwitchType::kSimple, false },
|
||||
{ L"SO", NSwitchType::kSimple, false },
|
||||
@@ -106,6 +112,7 @@ static void PrintHelp()
|
||||
" -lp{N}: set number of literal pos bits - [0, 4], default: 0\n"
|
||||
" -pb{N}: set number of pos bits - [0, 4], default: 2\n"
|
||||
" -mf{MF_ID}: set Match Finder: [bt2, bt3, bt4, hc4], default: bt4\n"
|
||||
" -mt{N}: set number of CPU threads\n"
|
||||
" -eos: write End Of Stream marker\n"
|
||||
" -si: read data from stdin\n"
|
||||
" -so: write data to stdout\n"
|
||||
@@ -152,7 +159,7 @@ int main2(int n, const char *args[])
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
|
||||
fprintf(stderr, "\nLZMA 4.44 Copyright (c) 1999-2006 Igor Pavlov 2006-12-26\n");
|
||||
fprintf(stderr, "\nLZMA 4.45 Copyright (c) 1999-2007 Igor Pavlov 2007-04-03\n");
|
||||
|
||||
if (n == 1)
|
||||
{
|
||||
@@ -192,7 +199,7 @@ int main2(int n, const char *args[])
|
||||
const UString &command = nonSwitchStrings[paramIndex++];
|
||||
|
||||
bool dictionaryIsDefined = false;
|
||||
UInt32 dictionary = 1 << 21;
|
||||
UInt32 dictionary = (UInt32)-1;
|
||||
if(parser[NKey::kDictionary].ThereIs)
|
||||
{
|
||||
UInt32 dicLog;
|
||||
@@ -205,18 +212,36 @@ int main2(int n, const char *args[])
|
||||
if (parser[NKey::kMatchFinder].ThereIs)
|
||||
mf = parser[NKey::kMatchFinder].PostStrings[0];
|
||||
|
||||
UInt32 numThreads = (UInt32)-1;
|
||||
|
||||
#ifdef COMPRESS_MF_MT
|
||||
if (parser[NKey::kMultiThread].ThereIs)
|
||||
{
|
||||
UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
|
||||
const UString &s = parser[NKey::kMultiThread].PostStrings[0];
|
||||
if (s.IsEmpty())
|
||||
numThreads = numCPUs;
|
||||
else
|
||||
if (!GetNumber(s, numThreads))
|
||||
IncorrectCommand();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (command.CompareNoCase(L"b") == 0)
|
||||
{
|
||||
const UInt32 kNumDefaultItereations = 10;
|
||||
const UInt32 kNumDefaultItereations = 1;
|
||||
UInt32 numIterations = kNumDefaultItereations;
|
||||
{
|
||||
if (paramIndex < nonSwitchStrings.Size())
|
||||
if (!GetNumber(nonSwitchStrings[paramIndex++], numIterations))
|
||||
numIterations = kNumDefaultItereations;
|
||||
}
|
||||
return LzmaBenchmark(stderr, numIterations, dictionary);
|
||||
return LzmaBenchCon(stderr, numIterations, numThreads, dictionary);
|
||||
}
|
||||
|
||||
if (numThreads == (UInt32)-1)
|
||||
numThreads = 1;
|
||||
|
||||
bool encodeMode = false;
|
||||
if (command.CompareNoCase(L"e") == 0)
|
||||
encodeMode = true;
|
||||
@@ -393,41 +418,35 @@ int main2(int n, const char *args[])
|
||||
NCoderPropID::kNumFastBytes,
|
||||
NCoderPropID::kMatchFinder,
|
||||
NCoderPropID::kEndMarker,
|
||||
NCoderPropID::kMatchFinderCycles
|
||||
NCoderPropID::kNumThreads,
|
||||
NCoderPropID::kMatchFinderCycles,
|
||||
};
|
||||
const int kNumPropsMax = sizeof(propIDs) / sizeof(propIDs[0]);
|
||||
/*
|
||||
NWindows::NCOM::CPropVariant properties[kNumProps];
|
||||
properties[0] = UInt32(dictionary);
|
||||
properties[1] = UInt32(posStateBits);
|
||||
properties[2] = UInt32(litContextBits);
|
||||
|
||||
properties[3] = UInt32(litPosBits);
|
||||
properties[4] = UInt32(algorithm);
|
||||
properties[5] = UInt32(numFastBytes);
|
||||
properties[6] = mf;
|
||||
properties[7] = eos;
|
||||
*/
|
||||
|
||||
PROPVARIANT properties[kNumPropsMax];
|
||||
for (int p = 0; p < 6; p++)
|
||||
properties[p].vt = VT_UI4;
|
||||
|
||||
properties[0].ulVal = UInt32(dictionary);
|
||||
properties[1].ulVal = UInt32(posStateBits);
|
||||
properties[2].ulVal = UInt32(litContextBits);
|
||||
properties[3].ulVal = UInt32(litPosBits);
|
||||
properties[4].ulVal = UInt32(algorithm);
|
||||
properties[5].ulVal = UInt32(numFastBytes);
|
||||
properties[0].ulVal = (UInt32)dictionary;
|
||||
properties[1].ulVal = (UInt32)posStateBits;
|
||||
properties[2].ulVal = (UInt32)litContextBits;
|
||||
properties[3].ulVal = (UInt32)litPosBits;
|
||||
properties[4].ulVal = (UInt32)algorithm;
|
||||
properties[5].ulVal = (UInt32)numFastBytes;
|
||||
|
||||
properties[8].vt = VT_UI4;
|
||||
properties[8].ulVal = UInt32(matchFinderCycles);
|
||||
|
||||
properties[6].vt = VT_BSTR;
|
||||
properties[6].bstrVal = (BSTR)(const wchar_t *)mf;
|
||||
|
||||
properties[7].vt = VT_BOOL;
|
||||
properties[7].boolVal = eos ? VARIANT_TRUE : VARIANT_FALSE;
|
||||
|
||||
properties[8].vt = VT_UI4;
|
||||
properties[8].ulVal = (UInt32)numThreads;
|
||||
|
||||
// it must be last in property list
|
||||
properties[9].vt = VT_UI4;
|
||||
properties[9].ulVal = (UInt32)matchFinderCycles;
|
||||
|
||||
int numProps = kNumPropsMax;
|
||||
if (!matchFinderCyclesDefined)
|
||||
numProps--;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,48 @@
|
||||
// LzmaBench.h
|
||||
|
||||
#ifndef __LzmaBench_h
|
||||
#define __LzmaBench_h
|
||||
#ifndef __LZMABENCH_H
|
||||
#define __LZMABENCH_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../../../Common/Types.h"
|
||||
#ifdef EXTERNAL_LZMA
|
||||
#include "../../UI/Common/LoadCodecs.h"
|
||||
#endif
|
||||
|
||||
int LzmaBenchmark(FILE *f, UInt32 numIterations, UInt32 dictionarySize);
|
||||
struct CBenchInfo
|
||||
{
|
||||
UInt64 GlobalTime;
|
||||
UInt64 GlobalFreq;
|
||||
UInt64 UserTime;
|
||||
UInt64 UserFreq;
|
||||
UInt64 UnpackSize;
|
||||
UInt64 PackSize;
|
||||
UInt32 NumIterations;
|
||||
CBenchInfo(): NumIterations(0) {}
|
||||
};
|
||||
|
||||
struct IBenchCallback
|
||||
{
|
||||
virtual HRESULT SetEncodeResult(const CBenchInfo &info, bool final) = 0;
|
||||
virtual HRESULT SetDecodeResult(const CBenchInfo &info, bool final) = 0;
|
||||
};
|
||||
|
||||
UInt64 GetUsage(const CBenchInfo &benchOnfo);
|
||||
UInt64 GetRatingPerUsage(const CBenchInfo &info, UInt64 rating);
|
||||
UInt64 GetCompressRating(UInt32 dictionarySize, UInt64 elapsedTime, UInt64 freq, UInt64 size);
|
||||
UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt32 numIterations);
|
||||
|
||||
HRESULT LzmaBench(
|
||||
#ifdef EXTERNAL_LZMA
|
||||
CCodecs *codecs,
|
||||
#endif
|
||||
UInt32 numThreads, UInt32 dictionarySize, IBenchCallback *callback);
|
||||
|
||||
const int kBenchMinDicLogSize = 18;
|
||||
|
||||
UInt64 GetBenchMemoryUsage(UInt32 numThreads, UInt32 dictionary);
|
||||
|
||||
bool CrcInternalTest();
|
||||
HRESULT CrcBench(UInt32 numThreads, UInt32 bufferSize, UInt64 &speed);
|
||||
|
||||
#endif
|
||||
|
||||
298
CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp
Executable file
298
CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp
Executable file
@@ -0,0 +1,298 @@
|
||||
// LzmaBenchCon.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "LzmaBench.h"
|
||||
#include "LzmaBenchCon.h"
|
||||
|
||||
#if defined(BENCH_MT) || defined(_WIN32)
|
||||
#include "Windows/System.h"
|
||||
#endif
|
||||
|
||||
#ifdef BREAK_HANDLER
|
||||
#include "../../UI/Console/ConsoleClose.h"
|
||||
#endif
|
||||
#include "../../../Common/MyCom.h"
|
||||
|
||||
struct CTotalBenchRes
|
||||
{
|
||||
UInt64 NumIterations;
|
||||
UInt64 Rating;
|
||||
UInt64 Usage;
|
||||
UInt64 RPU;
|
||||
void Init() { NumIterations = 0; Rating = 0; Usage = 0; RPU = 0; }
|
||||
void Normalize()
|
||||
{
|
||||
if (NumIterations == 0)
|
||||
return;
|
||||
Rating /= NumIterations;
|
||||
Usage /= NumIterations;
|
||||
RPU /= NumIterations;
|
||||
NumIterations = 1;
|
||||
}
|
||||
void SetMid(const CTotalBenchRes &r1, const CTotalBenchRes &r2)
|
||||
{
|
||||
Rating = (r1.Rating + r2.Rating) / 2;
|
||||
Usage = (r1.Usage + r2.Usage) / 2;
|
||||
RPU = (r1.RPU + r2.RPU) / 2;
|
||||
NumIterations = (r1.NumIterations + r2.NumIterations) / 2;
|
||||
}
|
||||
};
|
||||
|
||||
struct CBenchCallback: public IBenchCallback
|
||||
{
|
||||
CTotalBenchRes EncodeRes;
|
||||
CTotalBenchRes DecodeRes;
|
||||
FILE *f;
|
||||
void Init() { EncodeRes.Init(); DecodeRes.Init(); }
|
||||
void Normalize() { EncodeRes.Normalize(); DecodeRes.Normalize(); }
|
||||
UInt32 dictionarySize;
|
||||
HRESULT SetEncodeResult(const CBenchInfo &info, bool final);
|
||||
HRESULT SetDecodeResult(const CBenchInfo &info, bool final);
|
||||
};
|
||||
|
||||
static void NormalizeVals(UInt64 &v1, UInt64 &v2)
|
||||
{
|
||||
while (v1 > 1000000)
|
||||
{
|
||||
v1 >>= 1;
|
||||
v2 >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
static UInt64 MyMultDiv64(UInt64 value, UInt64 elapsedTime, UInt64 freq)
|
||||
{
|
||||
UInt64 elTime = elapsedTime;
|
||||
NormalizeVals(freq, elTime);
|
||||
if (elTime == 0)
|
||||
elTime = 1;
|
||||
return value * freq / elTime;
|
||||
}
|
||||
|
||||
static void PrintRating(FILE *f, UInt64 rating)
|
||||
{
|
||||
fprintf(f, " %6d", (unsigned int)(rating / 1000000));
|
||||
}
|
||||
|
||||
static void PrintResults(FILE *f, UInt64 usage, UInt64 rpu, UInt64 rating)
|
||||
{
|
||||
fprintf(f, " %5d", (usage + 5000) / 10000);
|
||||
PrintRating(f, rpu);
|
||||
PrintRating(f, rating);
|
||||
}
|
||||
|
||||
|
||||
static void PrintResults(FILE *f, const CBenchInfo &info, UInt64 rating, CTotalBenchRes &res)
|
||||
{
|
||||
UInt64 speed = MyMultDiv64(info.UnpackSize, info.GlobalTime, info.GlobalFreq);
|
||||
fprintf(f, "%7d", (unsigned int)(speed / 1024));
|
||||
UInt64 usage = GetUsage(info);
|
||||
UInt64 rpu = GetRatingPerUsage(info, rating);
|
||||
PrintResults(f, usage, rpu, rating);
|
||||
res.NumIterations++;
|
||||
res.RPU += rpu;
|
||||
res.Rating += rating;
|
||||
res.Usage += usage;
|
||||
}
|
||||
|
||||
static void PrintTotals(FILE *f, const CTotalBenchRes &res)
|
||||
{
|
||||
fprintf(f, " ");
|
||||
PrintResults(f, res.Usage, res.RPU, res.Rating);
|
||||
}
|
||||
|
||||
|
||||
HRESULT CBenchCallback::SetEncodeResult(const CBenchInfo &info, bool final)
|
||||
{
|
||||
#ifdef BREAK_HANDLER
|
||||
if (NConsoleClose::TestBreakSignal())
|
||||
return E_ABORT;
|
||||
#endif
|
||||
|
||||
if (final)
|
||||
{
|
||||
UInt64 rating = GetCompressRating(dictionarySize, info.GlobalTime, info.GlobalFreq, info.UnpackSize);
|
||||
PrintResults(f, info, rating, EncodeRes);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const char *kSep = " | ";
|
||||
|
||||
|
||||
HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final)
|
||||
{
|
||||
#ifdef BREAK_HANDLER
|
||||
if (NConsoleClose::TestBreakSignal())
|
||||
return E_ABORT;
|
||||
#endif
|
||||
if (final)
|
||||
{
|
||||
UInt64 rating = GetDecompressRating(info.GlobalTime, info.GlobalFreq, info.UnpackSize, info.PackSize, info.NumIterations);
|
||||
fprintf(f, kSep);
|
||||
CBenchInfo info2 = info;
|
||||
info2.GlobalTime /= info.NumIterations;
|
||||
info2.UserTime /= info.NumIterations;
|
||||
PrintResults(f, info2, rating, DecodeRes);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static void PtintRequirements(FILE *f, const char *sizeString, UInt64 size, const char *threadsString, UInt32 numThreads)
|
||||
{
|
||||
fprintf(f, "\nRAM %s %5d MB, # %s %3d", sizeString,
|
||||
(unsigned int)(size >> 20), threadsString, (unsigned int)numThreads);
|
||||
}
|
||||
|
||||
HRESULT LzmaBenchCon(
|
||||
#ifdef EXTERNAL_LZMA
|
||||
CCodecs *codecs,
|
||||
#endif
|
||||
FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary)
|
||||
{
|
||||
if (!CrcInternalTest())
|
||||
return S_FALSE;
|
||||
#ifdef BENCH_MT
|
||||
UInt64 ramSize = NWindows::NSystem::GetRamSize(); //
|
||||
UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
|
||||
PtintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
|
||||
if (numThreads == (UInt32)-1)
|
||||
numThreads = numCPUs;
|
||||
if (numThreads > 1)
|
||||
numThreads &= ~1;
|
||||
if (dictionary == (UInt32)-1)
|
||||
{
|
||||
int dicSizeLog;
|
||||
for (dicSizeLog = 25; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--)
|
||||
if (GetBenchMemoryUsage(numThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize)
|
||||
break;
|
||||
dictionary = (1 << dicSizeLog);
|
||||
}
|
||||
#else
|
||||
if (dictionary == (UInt32)-1)
|
||||
dictionary = (1 << 22);
|
||||
numThreads = 1;
|
||||
#endif
|
||||
|
||||
PtintRequirements(f, "usage:", GetBenchMemoryUsage(numThreads, dictionary), "Benchmark threads: ", numThreads);
|
||||
|
||||
CBenchCallback callback;
|
||||
callback.Init();
|
||||
callback.f = f;
|
||||
|
||||
fprintf(f, "\n\nDict Compressing | Decompressing\n ");
|
||||
int j;
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
fprintf(f, " Speed Usage R/U Rating");
|
||||
if (j == 0)
|
||||
fprintf(f, kSep);
|
||||
}
|
||||
fprintf(f, "\n ");
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
fprintf(f, " KB/s %% MIPS MIPS");
|
||||
if (j == 0)
|
||||
fprintf(f, kSep);
|
||||
}
|
||||
fprintf(f, "\n\n");
|
||||
for (UInt32 i = 0; i < numIterations; i++)
|
||||
{
|
||||
const int kStartDicLog = 22;
|
||||
int pow = (dictionary < ((UInt32)1 << kStartDicLog)) ? kBenchMinDicLogSize : kStartDicLog;
|
||||
while (((UInt32)1 << pow) > dictionary)
|
||||
pow--;
|
||||
for (; ((UInt32)1 << pow) <= dictionary; pow++)
|
||||
{
|
||||
fprintf(f, "%2d: ", pow);
|
||||
callback.dictionarySize = (UInt32)1 << pow;
|
||||
HRESULT res = LzmaBench(
|
||||
#ifdef EXTERNAL_LZMA
|
||||
codecs,
|
||||
#endif
|
||||
numThreads, callback.dictionarySize, &callback);
|
||||
fprintf(f, "\n");
|
||||
RINOK(res);
|
||||
}
|
||||
}
|
||||
callback.Normalize();
|
||||
fprintf(f, "----------------------------------------------------------------\nAvr:");
|
||||
PrintTotals(f, callback.EncodeRes);
|
||||
fprintf(f, " ");
|
||||
PrintTotals(f, callback.DecodeRes);
|
||||
fprintf(f, "\nTot:");
|
||||
CTotalBenchRes midRes;
|
||||
midRes.SetMid(callback.EncodeRes, callback.DecodeRes);
|
||||
PrintTotals(f, midRes);
|
||||
fprintf(f, "\n");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
struct CTempValues
|
||||
{
|
||||
UInt64 *Values;
|
||||
CTempValues(UInt32 num) { Values = new UInt64[num]; }
|
||||
~CTempValues() { delete []Values; }
|
||||
};
|
||||
|
||||
HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary)
|
||||
{
|
||||
if (!CrcInternalTest())
|
||||
return S_FALSE;
|
||||
|
||||
#ifdef BENCH_MT
|
||||
UInt64 ramSize = NWindows::NSystem::GetRamSize();
|
||||
UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
|
||||
PtintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
|
||||
if (numThreads == (UInt32)-1)
|
||||
numThreads = numCPUs;
|
||||
#else
|
||||
numThreads = 1;
|
||||
#endif
|
||||
if (dictionary == (UInt32)-1)
|
||||
dictionary = (1 << 24);
|
||||
|
||||
CTempValues speedTotals(numThreads);
|
||||
fprintf(f, "\n\nSize");
|
||||
for (UInt32 ti = 0; ti < numThreads; ti++)
|
||||
{
|
||||
fprintf(f, " %5d", ti + 1);
|
||||
speedTotals.Values[ti] = 0;
|
||||
}
|
||||
fprintf(f, "\n\n");
|
||||
|
||||
UInt64 numSteps = 0;
|
||||
for (UInt32 i = 0; i < numIterations; i++)
|
||||
{
|
||||
for (int pow = 10; pow < 32; pow++)
|
||||
{
|
||||
UInt32 bufSize = (UInt32)1 << pow;
|
||||
if (bufSize > dictionary)
|
||||
break;
|
||||
fprintf(f, "%2d: ", pow);
|
||||
UInt64 speed;
|
||||
for (UInt32 ti = 0; ti < numThreads; ti++)
|
||||
{
|
||||
#ifdef BREAK_HANDLER
|
||||
if (NConsoleClose::TestBreakSignal())
|
||||
return E_ABORT;
|
||||
#endif
|
||||
RINOK(CrcBench(ti + 1, bufSize, speed));
|
||||
fprintf(f, " %5d", (unsigned int)(speed >> 20));
|
||||
speedTotals.Values[ti] += speed;
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
numSteps++;
|
||||
}
|
||||
}
|
||||
if (numSteps != 0)
|
||||
{
|
||||
fprintf(f, "\nAvg:");
|
||||
for (UInt32 ti = 0; ti < numThreads; ti++)
|
||||
fprintf(f, " %5d", (unsigned int)((speedTotals.Values[ti] / numSteps) >> 20));
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
20
CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.h
Executable file
20
CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.h
Executable file
@@ -0,0 +1,20 @@
|
||||
// LzmaBenchCon.h
|
||||
|
||||
#ifndef __LZMABENCHCON_H
|
||||
#define __LZMABENCHCON_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../../../Common/Types.h"
|
||||
#ifdef EXTERNAL_LZMA
|
||||
#include "../../UI/Common/LoadCodecs.h"
|
||||
#endif
|
||||
HRESULT LzmaBenchCon(
|
||||
#ifdef EXTERNAL_LZMA
|
||||
CCodecs *codecs,
|
||||
#endif
|
||||
FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary);
|
||||
|
||||
HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
PROG = lzma.exe
|
||||
CFLAGS = $(CFLAGS) -I ../../../
|
||||
CFLAGS = $(CFLAGS) -I ../../../ \
|
||||
-DCOMPRESS_MF_MT \
|
||||
-DBENCH_MT \
|
||||
|
||||
LIBS = $(LIBS) oleaut32.lib user32.lib
|
||||
|
||||
!IFDEF CPU
|
||||
@@ -23,8 +26,7 @@ CFLAGS = $(CFLAGS) -MT
|
||||
CFLAGS = $(CFLAGS) -MD
|
||||
!ENDIF
|
||||
|
||||
|
||||
CFLAGS = $(CFLAGS) -nologo -EHsc -c -Fo$O/ -WX
|
||||
CFLAGS = $(CFLAGS) -nologo -EHsc -c -Fo$O/
|
||||
CFLAGS_O1 = $(CFLAGS) -O1
|
||||
CFLAGS_O2 = $(CFLAGS) -O2
|
||||
|
||||
@@ -40,6 +42,7 @@ COMPL = $(CPP) $(CFLAGS_O1) $**
|
||||
LZMA_OBJS = \
|
||||
$O\LzmaAlone.obj \
|
||||
$O\LzmaBench.obj \
|
||||
$O\LzmaBenchCon.obj \
|
||||
$O\LzmaRam.obj \
|
||||
|
||||
LZMA_OPT_OBJS = \
|
||||
@@ -47,9 +50,8 @@ LZMA_OPT_OBJS = \
|
||||
$O\LZMAEncoder.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\CRC.obj \
|
||||
$O\CommandLineParser.obj \
|
||||
$O\CRC.obj \
|
||||
$O\String.obj \
|
||||
$O\StringConvert.obj \
|
||||
$O\StringToInt.obj \
|
||||
@@ -64,10 +66,13 @@ LZ_OBJS = \
|
||||
$O\LZOutWindow.obj \
|
||||
|
||||
C_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\7zCrc.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
C_LZ_OBJS = \
|
||||
$O\MatchFinder.obj \
|
||||
$O\MatchFinderMt.obj \
|
||||
|
||||
OBJS = \
|
||||
$(LZMA_OBJS) \
|
||||
|
||||
@@ -8,6 +8,7 @@ CFLAGS = -c -I ../../../
|
||||
OBJS = \
|
||||
LzmaAlone.o \
|
||||
LzmaBench.o \
|
||||
LzmaBenchCon.o \
|
||||
LzmaRam.o \
|
||||
LzmaRamDecode.o \
|
||||
LzmaDecode.o \
|
||||
@@ -43,6 +44,9 @@ LzmaAlone.o: LzmaAlone.cpp
|
||||
LzmaBench.o: LzmaBench.cpp
|
||||
$(CXX) $(CFLAGS) LzmaBench.cpp
|
||||
|
||||
LzmaBenchCon.o: LzmaBenchCon.cpp
|
||||
$(CXX) $(CFLAGS) LzmaBenchCon.cpp
|
||||
|
||||
LzmaRam.o: LzmaRam.cpp
|
||||
$(CXX) $(CFLAGS) LzmaRam.cpp
|
||||
|
||||
@@ -67,6 +71,10 @@ MatchFinder.o: ../../../../C/Compress/Lz/MatchFinder.c
|
||||
7zCrc.o: ../../../../C/7zCrc.c
|
||||
$(CXX_C) $(CFLAGS) ../../../../C/7zCrc.c
|
||||
|
||||
Alloc.o: ../../../../Alloc.cpp
|
||||
$(CXX) $(CFLAGS) ../../../../Alloc.c
|
||||
|
||||
|
||||
LZOutWindow.o: ../LZ/LZOutWindow.cpp
|
||||
$(CXX) $(CFLAGS) ../LZ/LZOutWindow.cpp
|
||||
|
||||
@@ -85,9 +93,6 @@ FileStreams.o: ../../Common/FileStreams.cpp
|
||||
StreamUtils.o: ../../Common/StreamUtils.cpp
|
||||
$(CXX) $(CFLAGS) ../../Common/StreamUtils.cpp
|
||||
|
||||
Alloc.o: ../../../Common/Alloc.cpp
|
||||
$(CXX) $(CFLAGS) ../../../Common/Alloc.cpp
|
||||
|
||||
C_FileIO.o: ../../../Common/C_FileIO.cpp
|
||||
$(CXX) $(CFLAGS) ../../../Common/C_FileIO.cpp
|
||||
|
||||
|
||||
Reference in New Issue
Block a user