From cc8df6e51059b7e70f81418162d08f40ced63084 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sun, 21 Dec 2014 17:13:50 +0100 Subject: [PATCH] Make the initialization time measurement work again. --- src/Config.h | 2 +- src/Main.cpp | 6 +-- src/Thread_Initialization.cpp | 70 ++--------------------------------- src/Thread_Initialization.h | 1 - 4 files changed, 8 insertions(+), 71 deletions(-) diff --git a/src/Config.h b/src/Config.h index aff46bab..32306c82 100644 --- a/src/Config.h +++ b/src/Config.h @@ -35,7 +35,7 @@ #define VER_LAMEXP_MINOR_LO 1 #define VER_LAMEXP_TYPE Beta #define VER_LAMEXP_PATCH 10 -#define VER_LAMEXP_BUILD 1646 +#define VER_LAMEXP_BUILD 1649 #define VER_LAMEXP_CONFG 1558 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Main.cpp b/src/Main.cpp index d4ab54a1..0cf35af8 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -42,10 +42,10 @@ #include //Qt includes +#include #include #include #include -#include #include //VLD @@ -170,7 +170,7 @@ static int lamexp_main(int &argc, char **argv) { int iResult = -1; int iShutdown = SHUTDOWN_FLAG_NONE; - + //Print logo lamexp_print_logo(); @@ -262,5 +262,5 @@ static int lamexp_main(int &argc, char **argv) int main(int argc, char* argv[]) { - return MUtils::Startup::startup(argc, argv, lamexp_main, lamexp_version_demo()); + return MUtils::Startup::startup(argc, argv, lamexp_main, "LameXP", lamexp_version_demo()); } diff --git a/src/Thread_Initialization.cpp b/src/Thread_Initialization.cpp index 26b0121e..d09b90c3 100644 --- a/src/Thread_Initialization.cpp +++ b/src/Thread_Initialization.cpp @@ -56,9 +56,6 @@ static const double g_allowedExtractDelay = 12.0; static const size_t BUFF_SIZE = 512; static const size_t EXPECTED_TOOL_COUNT = 28; -/* benchmark */ -#undef ENABLE_BENCHMARK - /* number of CPU cores -> number of threads */ static unsigned int cores2threads(const unsigned int cores) { @@ -225,17 +222,11 @@ InitializationThread::InitializationThread(const MUtils::CPUFetaures::cpu_info_t // Thread Main //////////////////////////////////////////////////////////// -#ifdef ENABLE_BENCHMARK -#define DO_INIT_FUNCT runBenchmark -#else //ENABLE_BENCHMARK -#define DO_INIT_FUNCT doInit -#endif //ENABLE_BENCHMARK - void InitializationThread::run(void) { try { - DO_INIT_FUNCT(); + doInit(); } catch(const std::exception &error) { @@ -370,7 +361,7 @@ double InitializationThread::doInit(const size_t threadCount) MUTILS_DELETE(pool); //Performance measure - const qint64 delayExtract = timeExtractStart.elapsed(); + const double delayExtract = double(timeExtractStart.elapsed()) / 1000.0; timeExtractStart.invalidate(); //Make sure all files were extracted correctly @@ -395,7 +386,7 @@ double InitializationThread::doInit(const size_t threadCount) } //Check delay - if((double(delayExtract) / 1000.0) > g_allowedExtractDelay) + if(delayExtract > g_allowedExtractDelay) { m_slowIndicator = true; qWarning("Extracting tools took %.3f seconds -> probably slow realtime virus scanner.", delayExtract); @@ -403,7 +394,7 @@ double InitializationThread::doInit(const size_t threadCount) } else { - qDebug("Extracting the tools took %.5f seconds (OK).\n", delayExtract); + qDebug("Extracting the tools took %.3f seconds (OK).\n", delayExtract); } //Register all translations @@ -420,59 +411,6 @@ double InitializationThread::doInit(const size_t threadCount) return delayExtract; } -void InitializationThread::runBenchmark(void) -{ -#ifdef ENABLE_BENCHMARK - static const size_t nLoops = 5; - const size_t maxThreads = (5 * m_cpuFeatures.count); - QMap results; - - for(size_t c = 1; c <= maxThreads; c++) - { - QList delayLst; - double delayAvg = 0.0; - for(size_t i = 0; i < nLoops; i++) - { - delayLst << doInit(c); - lamexp_clean_all_tools(); - } - qSort(delayLst.begin(), delayLst.end()); - delayLst.takeLast(); - delayLst.takeFirst(); - for(QList::ConstIterator iter = delayLst.constBegin(); iter != delayLst.constEnd(); iter++) - { - delayAvg += (*iter); - } - results.insert(c, (delayAvg / double(delayLst.count()))); - } - - qWarning("\n----------------------------------------------"); - qWarning("Benchmark Results:"); - qWarning("----------------------------------------------"); - - double bestTime = DBL_MAX; size_t bestVal = 0; - QList keys = results.keys(); - for(QList::ConstIterator iter = keys.begin(); iter != keys.end(); iter++) - { - const double time = results.value((*iter), DBL_MAX); - qWarning("%02u -> %7.4f", (*iter), time); - if(time < bestTime) - { - bestTime = time; - bestVal = (*iter); - } - } - - qWarning("----------------------------------------------"); - qWarning("BEST: %u of %u (factor: %7.4f)", bestVal, m_cpuFeatures.count, (double(bestVal) / double(m_cpuFeatures.count))); - qWarning("----------------------------------------------\n"); - - qFatal("Benchmark complete. Thanks and bye bye!"); -#else //ENABLE_BENCHMARK - MUTILS_THROW("Sorry, the benchmark is *not* available in this build!"); -#endif //ENABLE_BENCHMARK -} - //////////////////////////////////////////////////////////// // PUBLIC FUNCTIONS //////////////////////////////////////////////////////////// diff --git a/src/Thread_Initialization.h b/src/Thread_Initialization.h index 891fb2af..0cf2bfc3 100644 --- a/src/Thread_Initialization.h +++ b/src/Thread_Initialization.h @@ -50,7 +50,6 @@ public: protected: void run(void); double doInit(const size_t threadCount = 0); - void runBenchmark(void); private: void delay(void);