From 478c2f209958a9e7d93780228d7fb15f2329ce5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20St=C3=B6ggl?= Date: Sat, 22 Feb 2020 16:51:52 +0100 Subject: [PATCH 01/11] Use _WIN32 instead of WIN32 preprocessor macro (#138) - _WIN32 is the recommended preprocessor macro - Substitute occurrences of WIN32 with _WIN32 using: git grep -lw -e 'WIN32' -- | xargs sed -i -e 's/\/_WIN32/g' --- README.md | 2 +- experiments/DemoSimple/DemoSimple.cpp | 2 +- .../DemoSimpleJUnit/DemoSimpleJUnit.cpp | 2 +- experiments/DemoTransform/DemoTransform.cpp | 2 +- .../ExperimentSortingRandomInts.cpp | 2 +- .../ExperimentSortingRandomIntsUDM.cpp | 2 +- include/celero/Celero.h | 2 +- include/celero/CommandLine.h | 4 +-- include/celero/Export.h | 2 +- include/celero/Utilities.h | 2 +- src/Console.cpp | 36 +++++++++---------- src/Exceptions.cpp | 4 +-- src/Memory.cpp | 28 +++++++-------- src/Timer.cpp | 6 ++-- src/Utilities.cpp | 2 +- 15 files changed, 49 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 5b83f2d..151f5d1 100644 --- a/README.md +++ b/README.md @@ -166,7 +166,7 @@ Here is an example of a simple Celero Benchmark. (Note: This is a complete, runn #include -#ifndef WIN32 +#ifndef _WIN32 #include #include #endif diff --git a/experiments/DemoSimple/DemoSimple.cpp b/experiments/DemoSimple/DemoSimple.cpp index 2a0a0c3..f0c300f 100644 --- a/experiments/DemoSimple/DemoSimple.cpp +++ b/experiments/DemoSimple/DemoSimple.cpp @@ -2,7 +2,7 @@ #include -#ifndef WIN32 +#ifndef _WIN32 #include #include #endif diff --git a/experiments/DemoSimpleJUnit/DemoSimpleJUnit.cpp b/experiments/DemoSimpleJUnit/DemoSimpleJUnit.cpp index 86c47c1..0be4ac2 100644 --- a/experiments/DemoSimpleJUnit/DemoSimpleJUnit.cpp +++ b/experiments/DemoSimpleJUnit/DemoSimpleJUnit.cpp @@ -1,6 +1,6 @@ #include -#ifndef WIN32 +#ifndef _WIN32 #include #include #endif diff --git a/experiments/DemoTransform/DemoTransform.cpp b/experiments/DemoTransform/DemoTransform.cpp index 25b37a2..55e7e60 100644 --- a/experiments/DemoTransform/DemoTransform.cpp +++ b/experiments/DemoTransform/DemoTransform.cpp @@ -4,7 +4,7 @@ #include #include -#ifndef WIN32 +#ifndef _WIN32 #include #include #endif diff --git a/experiments/ExperimentSortingRandomInts/ExperimentSortingRandomInts.cpp b/experiments/ExperimentSortingRandomInts/ExperimentSortingRandomInts.cpp index 0f3b8ed..e8f85c5 100644 --- a/experiments/ExperimentSortingRandomInts/ExperimentSortingRandomInts.cpp +++ b/experiments/ExperimentSortingRandomInts/ExperimentSortingRandomInts.cpp @@ -1,7 +1,7 @@ #include #include -#ifndef WIN32 +#ifndef _WIN32 #include #include #endif diff --git a/experiments/ExperimentSortingRandomIntsUDM/ExperimentSortingRandomIntsUDM.cpp b/experiments/ExperimentSortingRandomIntsUDM/ExperimentSortingRandomIntsUDM.cpp index e724fa2..8df7296 100644 --- a/experiments/ExperimentSortingRandomIntsUDM/ExperimentSortingRandomIntsUDM.cpp +++ b/experiments/ExperimentSortingRandomIntsUDM/ExperimentSortingRandomIntsUDM.cpp @@ -3,7 +3,7 @@ #include #include -#ifndef WIN32 +#ifndef _WIN32 #include #include #endif diff --git a/include/celero/Celero.h b/include/celero/Celero.h index aaf38ef..a7c91d4 100644 --- a/include/celero/Celero.h +++ b/include/celero/Celero.h @@ -31,7 +31,7 @@ /// It is highly encouraged to only run this code compiled in a "Release" mode to use all available optimizations. /// -#ifdef WIN32 +#ifdef _WIN32 #include #endif diff --git a/include/celero/CommandLine.h b/include/celero/CommandLine.h index 230417a..82204f9 100644 --- a/include/celero/CommandLine.h +++ b/include/celero/CommandLine.h @@ -38,7 +38,7 @@ #include #include -#ifndef WIN32 +#ifndef _WIN32 #include #endif @@ -115,7 +115,7 @@ namespace cmdline return lexical_cast_t::value>::cast(arg); } -#ifdef WIN32 +#ifdef _WIN32 static inline std::string demangle(const std::string &) { return std::string(); diff --git a/include/celero/Export.h b/include/celero/Export.h index b672b15..a074e37 100644 --- a/include/celero/Export.h +++ b/include/celero/Export.h @@ -23,7 +23,7 @@ #define CELERO_EXPORT #define CELERO_EXPORT_C #else -#ifdef WIN32 +#ifdef _WIN32 #if defined CELERO_EXPORTS #define CELERO_EXPORT _declspec(dllexport) #define CELERO_EXPORT_C extern "C" _declspec(dllexport) diff --git a/include/celero/Utilities.h b/include/celero/Utilities.h index 4f409e5..93e3c53 100644 --- a/include/celero/Utilities.h +++ b/include/celero/Utilities.h @@ -19,7 +19,7 @@ /// limitations under the License. /// -#ifndef WIN32 +#ifndef _WIN32 #include #endif diff --git a/src/Console.cpp b/src/Console.cpp index 91e2059..b4c62ec 100644 --- a/src/Console.cpp +++ b/src/Console.cpp @@ -20,14 +20,14 @@ using namespace celero; -#ifdef WIN32 +#ifdef _WIN32 #include #include #else #include #endif -#ifdef WIN32 +#ifdef _WIN32 auto WinColor() -> decltype(GetStdHandle(STD_OUTPUT_HANDLE)) { auto h = GetStdHandle(STD_OUTPUT_HANDLE); @@ -39,7 +39,7 @@ auto WinColor() -> decltype(GetStdHandle(STD_OUTPUT_HANDLE)) void Red() { -#ifdef WIN32 +#ifdef _WIN32 auto h = WinColor(); SetConsoleTextAttribute(h, FOREGROUND_RED); #else @@ -49,7 +49,7 @@ void Red() void RedBold() { -#ifdef WIN32 +#ifdef _WIN32 auto h = WinColor(); SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_INTENSITY); #else @@ -59,7 +59,7 @@ void RedBold() void Green() { -#ifdef WIN32 +#ifdef _WIN32 auto h = WinColor(); SetConsoleTextAttribute(h, FOREGROUND_GREEN); #else @@ -69,7 +69,7 @@ void Green() void GreenBold() { -#ifdef WIN32 +#ifdef _WIN32 auto h = WinColor(); SetConsoleTextAttribute(h, FOREGROUND_GREEN | FOREGROUND_INTENSITY); #else @@ -79,7 +79,7 @@ void GreenBold() void Blue() { -#ifdef WIN32 +#ifdef _WIN32 auto h = WinColor(); SetConsoleTextAttribute(h, FOREGROUND_BLUE); #else @@ -89,7 +89,7 @@ void Blue() void BlueBold() { -#ifdef WIN32 +#ifdef _WIN32 auto h = WinColor(); SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_INTENSITY); #else @@ -99,7 +99,7 @@ void BlueBold() void Cyan() { -#ifdef WIN32 +#ifdef _WIN32 auto h = WinColor(); SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN); #else @@ -109,7 +109,7 @@ void Cyan() void CyanBold() { -#ifdef WIN32 +#ifdef _WIN32 auto h = WinColor(); SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY); #else @@ -119,7 +119,7 @@ void CyanBold() void Yellow() { -#ifdef WIN32 +#ifdef _WIN32 auto h = WinColor(); SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN); #else @@ -129,7 +129,7 @@ void Yellow() void YellowBold() { -#ifdef WIN32 +#ifdef _WIN32 auto h = WinColor(); SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY); #else @@ -139,7 +139,7 @@ void YellowBold() void White() { -#ifdef WIN32 +#ifdef _WIN32 auto h = WinColor(); SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); #else @@ -149,7 +149,7 @@ void White() void WhiteBold() { -#ifdef WIN32 +#ifdef _WIN32 auto h = WinColor(); SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY); #else @@ -159,7 +159,7 @@ void WhiteBold() void WhiteOnRed() { -#ifdef WIN32 +#ifdef _WIN32 auto h = WinColor(); SetConsoleTextAttribute(h, BACKGROUND_RED | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); #else @@ -169,7 +169,7 @@ void WhiteOnRed() void WhiteOnRedBold() { -#ifdef WIN32 +#ifdef _WIN32 auto h = WinColor(); SetConsoleTextAttribute(h, BACKGROUND_RED | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY); #else @@ -179,7 +179,7 @@ void WhiteOnRedBold() void PurpleBold() { -#ifdef WIN32 +#ifdef _WIN32 auto h = WinColor(); SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY); #else @@ -189,7 +189,7 @@ void PurpleBold() void Default() { -#ifdef WIN32 +#ifdef _WIN32 White(); #else std::cout << "\033[0m"; diff --git a/src/Exceptions.cpp b/src/Exceptions.cpp index 9cb1918..3e8837b 100644 --- a/src/Exceptions.cpp +++ b/src/Exceptions.cpp @@ -21,9 +21,9 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 #include -#endif // WIN32 +#endif // _WIN32 #include #include diff --git a/src/Memory.cpp b/src/Memory.cpp index f1662d4..fde7f19 100644 --- a/src/Memory.cpp +++ b/src/Memory.cpp @@ -19,7 +19,7 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 #include #include @@ -53,7 +53,7 @@ using namespace celero; -#ifdef WIN32 +#ifdef _WIN32 #else constexpr int64_t Kilobytes2Bytes{1024}; @@ -120,7 +120,7 @@ celero::RAMReport celero::RAMReport::operator-(const RAMReport& x) int64_t celero::GetRAMSystemTotal() { -#ifdef WIN32 +#ifdef _WIN32 MEMORYSTATUSEX memInfo; memInfo.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&memInfo); @@ -155,7 +155,7 @@ int64_t celero::GetRAMSystemTotal() int64_t celero::GetRAMSystemAvailable() { -#ifdef WIN32 +#ifdef _WIN32 MEMORYSTATUSEX memInfo; memInfo.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&memInfo); @@ -167,7 +167,7 @@ int64_t celero::GetRAMSystemAvailable() int64_t celero::GetRAMSystemUsed() { -#ifdef WIN32 +#ifdef _WIN32 return celero::GetRAMSystemTotal() - celero::GetRAMSystemAvailable(); #elif defined(__APPLE__) int mib[2]; @@ -198,7 +198,7 @@ int64_t celero::GetRAMSystemUsed() int64_t celero::GetRAMSystemUsedByCurrentProcess() { -#ifdef WIN32 +#ifdef _WIN32 PROCESS_MEMORY_COUNTERS_EX pmc; GetProcessMemoryInfo(GetCurrentProcess(), reinterpret_cast(&pmc), sizeof(pmc)); return static_cast(pmc.WorkingSetSize); @@ -209,7 +209,7 @@ int64_t celero::GetRAMSystemUsedByCurrentProcess() int64_t celero::GetRAMPhysicalTotal() { -#ifdef WIN32 +#ifdef _WIN32 MEMORYSTATUSEX memInfo; memInfo.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&memInfo); @@ -225,7 +225,7 @@ int64_t celero::GetRAMPhysicalTotal() int64_t celero::GetRAMPhysicalAvailable() { -#ifdef WIN32 +#ifdef _WIN32 MEMORYSTATUSEX memInfo; memInfo.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&memInfo); @@ -237,7 +237,7 @@ int64_t celero::GetRAMPhysicalAvailable() int64_t celero::GetRAMPhysicalUsed() { -#ifdef WIN32 +#ifdef _WIN32 return celero::GetRAMPhysicalTotal() - celero::GetRAMPhysicalAvailable(); #elif defined(__APPLE__) struct rusage rusage; @@ -252,7 +252,7 @@ int64_t celero::GetRAMPhysicalUsed() int64_t celero::GetRAMPhysicalUsedByCurrentProcess() { -#ifdef WIN32 +#ifdef _WIN32 PROCESS_MEMORY_COUNTERS_EX pmc; GetProcessMemoryInfo(GetCurrentProcess(), reinterpret_cast(&pmc), sizeof(pmc)); return static_cast(pmc.WorkingSetSize); @@ -306,7 +306,7 @@ int64_t celero::GetRAMPhysicalUsedByCurrentProcessPeak() int64_t celero::GetRAMVirtualTotal() { -#ifdef WIN32 +#ifdef _WIN32 MEMORYSTATUSEX memInfo; memInfo.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&memInfo); @@ -322,7 +322,7 @@ int64_t celero::GetRAMVirtualTotal() int64_t celero::GetRAMVirtualAvailable() { -#ifdef WIN32 +#ifdef _WIN32 MEMORYSTATUSEX memInfo; memInfo.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&memInfo); @@ -334,7 +334,7 @@ int64_t celero::GetRAMVirtualAvailable() int64_t celero::GetRAMVirtualUsed() { -#ifdef WIN32 +#ifdef _WIN32 return celero::GetRAMVirtualTotal() - celero::GetRAMVirtualAvailable(); #elif defined(__APPLE__) return -1; @@ -348,7 +348,7 @@ int64_t celero::GetRAMVirtualUsed() int64_t celero::GetRAMVirtualUsedByCurrentProcess() { -#ifdef WIN32 +#ifdef _WIN32 PROCESS_MEMORY_COUNTERS_EX pmc; GetProcessMemoryInfo(GetCurrentProcess(), reinterpret_cast(&pmc), sizeof(pmc)); return pmc.PrivateUsage; diff --git a/src/Timer.cpp b/src/Timer.cpp index 7792722..fa24e74 100644 --- a/src/Timer.cpp +++ b/src/Timer.cpp @@ -20,7 +20,7 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 #include LARGE_INTEGER QPCFrequency; #else @@ -29,7 +29,7 @@ LARGE_INTEGER QPCFrequency; uint64_t celero::timer::GetSystemTime() { -#ifdef WIN32 +#ifdef _WIN32 LARGE_INTEGER timeStorage; QueryPerformanceCounter(&timeStorage); if(QPCFrequency.QuadPart != 0) @@ -46,7 +46,7 @@ uint64_t celero::timer::GetSystemTime() double celero::timer::CachePerformanceFrequency(bool quiet) { -#ifdef WIN32 +#ifdef _WIN32 QueryPerformanceFrequency(&QPCFrequency); if(QPCFrequency.QuadPart == 0) { diff --git a/src/Utilities.cpp b/src/Utilities.cpp index 6d9a266..0e4f1c4 100644 --- a/src/Utilities.cpp +++ b/src/Utilities.cpp @@ -19,7 +19,7 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 #include #include From c2b28ebc6f32aef7673913deed9d152da1866467 Mon Sep 17 00:00:00 2001 From: jiverson002 Date: Sat, 28 Mar 2020 16:35:40 -0500 Subject: [PATCH 02/11] Cleanup some compiler issues on MacOS. (#141) In file include/celero/ThreadLocal.h: * `thread_local` is a C++ keyword so using an #ifdef check for its existence is not reliable. Instead, check for C++11 support to determine if `thread_local` is already defined. See here https://stackoverflow.com/questions/5047971/how-do-i-check-for-c11-support. * Also the check `#if __STDC_VERSION__ >= 201112` is not meaningful, since presumably Celero is being compiled with a C++ compiler, so it has been removed. In file src/Memory.cpp: * Added include for `` so that `strlen` and `strncmp` are defined for Apple environment. Fixes #140 --- include/celero/ThreadLocal.h | 7 ++----- src/Memory.cpp | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/include/celero/ThreadLocal.h b/include/celero/ThreadLocal.h index 1ed8aa6..12a10a2 100644 --- a/include/celero/ThreadLocal.h +++ b/include/celero/ThreadLocal.h @@ -19,10 +19,8 @@ /// limitations under the License. /// -#ifndef thread_local - -#if __STDC_VERSION__ >= 201112 && !defined __STDC_NO_THREADS__ -#define thread_local _Thread_local +#if __cplusplus >= 201103L || defined _MSC_VER && _MSC_VER >= 1900 +/* do nothing, thread_local is a c++11 keyword */ #elif defined _WIN32 && (defined _MSC_VER || defined __ICL || defined __DMC__ || defined __BORLANDC__) #define thread_local __declspec(thread) /* note that ICC (linux) and Clang are covered by __GNUC__ */ @@ -31,6 +29,5 @@ #else #error "Cannot define thread_local" #endif -#endif #endif diff --git a/src/Memory.cpp b/src/Memory.cpp index fde7f19..6b3b35d 100644 --- a/src/Memory.cpp +++ b/src/Memory.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #else #include #include From 77081d9f15ef4ff0f5a239f2aaaa5c911dca56cb Mon Sep 17 00:00:00 2001 From: John Farrier Date: Tue, 28 Apr 2020 18:39:02 -0400 Subject: [PATCH 03/11] Made it easier to use the Fixed baseline properly with UDMs. --- README.md | 12 +++++++----- experiments/DemoTransform/DemoTransform.cpp | 4 ++-- include/celero/Celero.h | 12 ++++++------ src/Print.cpp | 2 ++ 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 151f5d1..0d7e777 100644 --- a/README.md +++ b/README.md @@ -306,7 +306,7 @@ Celero can automatically run threaded benchmarks. `BASELINE_T` and `BENCHMARK_T ```cpp BASELINE_T(groupName, baselineName, fixtureName, samples, iterations, threads); -BASELINE_FIXED_T(groupName, baselineName, fixtureName, samples, iterations, threads, useconds); +BASELINE_FIXED_T(groupName, baselineName, fixtureName, iterations, threads, useconds); BENCHMARK_T(groupName, benchmarkName, fixtureName, samples, iterations, threads); BENCHMARK_TEST_T(groupName, benchmarkName, fixtureName, samples, iterations, threads, target); @@ -318,22 +318,24 @@ While Celero typically measures the baseline time and then executes benchmark ca ```cpp // No threads or test fixtures. -BASELINE_FIXED(groupName, baselineName, samples, iterations, useconds); +BASELINE_FIXED(groupName, baselineName, iterations, useconds); // For using test fixtures: -BASELINE_FIXED_F(groupName, baselineName, fixtureName, samples, iterations, useconds); +BASELINE_FIXED_F(groupName, baselineName, fixtureName, iterations, useconds); // For using threads and test fixtures. -BASELINE_FIXED_T(groupName, baselineName, fixtureName, samples, iterations, threads, useconds); +BASELINE_FIXED_T(groupName, baselineName, fixtureName, iterations, threads, useconds); ``` Example: ```cpp -BASELINE_FIXED_F(DemoTransform, FixedTime, DemoTransformFixture, 30, 10000, 100) +BASELINE_FIXED_F(DemoTransform, FixedTime, DemoTransformFixture, 1, 100) { /* Nothing to do */ } ``` +It is important that if your measurements use a test fixture, that your baseline (even if fixed) should use a test fixture as well. Features such as User-Defined Measurements (UDMs) look to the baseline class to detect if other features are present. If the baseline does not use a test fixuture, Celero will not know that other classes do use a test fixture that offers a UDM. + ### User-Defined Measurements (UDM) Celero, by default, measures the execution time of your experiments. If you want to measure anything else, say for example the number of page faults via [PAPI](http://icl.cs.utk.edu/projects/papi/wiki/PAPIC:Overview), *user-defined measurements* are for you. diff --git a/experiments/DemoTransform/DemoTransform.cpp b/experiments/DemoTransform/DemoTransform.cpp index 55e7e60..1c1a4ca 100644 --- a/experiments/DemoTransform/DemoTransform.cpp +++ b/experiments/DemoTransform/DemoTransform.cpp @@ -101,8 +101,8 @@ BASELINE_F(DemoTransform, ForLoop, DemoTransformFixture, 30, 10000) } } -// BASELINE_FIXED_F(DemoTransform, FixedTime, DemoTransformFixture, 30, 10000, 100) -// { } +BASELINE_FIXED_F(DemoTransform, FixedTime, DemoTransformFixture, 1, 100) +{ } BENCHMARK_F(DemoTransform, StdTransform, DemoTransformFixture, 30, 10000) { diff --git a/include/celero/Celero.h b/include/celero/Celero.h index a7c91d4..9228621 100644 --- a/include/celero/Celero.h +++ b/include/celero/Celero.h @@ -305,11 +305,11 @@ namespace celero /// /// Using the BASELINE_ macro, this effectivly fills in a class's UserBenchmark() function. /// -#define BASELINE_FIXED(groupName, baselineName, samples, iterations, useconds) \ - BASELINE_IMPL(groupName, baselineName, ::celero::TestFixture, samples, iterations, 1, useconds) -#define BASELINE_FIXED_F(groupName, baselineName, fixtureName, samples, iterations, useconds) \ - BASELINE_IMPL(groupName, baselineName, fixtureName, samples, iterations, 1, useconds) -#define BASELINE_FIXED_T(groupName, baselineName, fixtureName, samples, iterations, threads, useconds) \ - BASELINE_IMPL(groupName, baselineName, fixtureName, samples, iterations, threads, useconds) +#define BASELINE_FIXED(groupName, baselineName, iterations, useconds) \ + BASELINE_IMPL(groupName, baselineName, ::celero::TestFixture, 1, iterations, 1, useconds) +#define BASELINE_FIXED_F(groupName, baselineName, fixtureName, iterations, useconds) \ + BASELINE_IMPL(groupName, baselineName, fixtureName, 1, iterations, 1, useconds) +#define BASELINE_FIXED_T(groupName, baselineName, fixtureName, iterations, threads, useconds) \ + BASELINE_IMPL(groupName, baselineName, fixtureName, 1, iterations, threads, useconds) #endif diff --git a/src/Print.cpp b/src/Print.cpp index 3172b73..d8433ad 100644 --- a/src/Print.cpp +++ b/src/Print.cpp @@ -315,6 +315,8 @@ namespace celero else { std::cout << PrintColumn(udmValues.at(fieldName), 2, this->columnWidths[i + PrintConstants::NumberOfColumns]); + celero::console::SetConsoleColor(celero::console::ConsoleColor::Default); + std::cout << " | "; } } From 734e57265ef6c30ed818def8e6d3fe0334665507 Mon Sep 17 00:00:00 2001 From: John Farrier Date: Fri, 8 May 2020 09:41:47 -0400 Subject: [PATCH 04/11] Improving the "cost of pimpl" experiment. --- .../ExperimentCostOfPimpl.cpp | 86 +++++++++++++------ 1 file changed, 62 insertions(+), 24 deletions(-) diff --git a/experiments/ExperimentCostOfPimpl/ExperimentCostOfPimpl.cpp b/experiments/ExperimentCostOfPimpl/ExperimentCostOfPimpl.cpp index 2be8bbd..9b1332a 100644 --- a/experiments/ExperimentCostOfPimpl/ExperimentCostOfPimpl.cpp +++ b/experiments/ExperimentCostOfPimpl/ExperimentCostOfPimpl.cpp @@ -26,7 +26,11 @@ class NoImpl return this->value; } -private: + void setValue(int x) + { + this->value = x; + } + int value; }; @@ -73,6 +77,11 @@ class RawPointer return this->pimpl->value; } + void setValue(int x) + { + this->pimpl->value = x; + } + private: GenericImpl* pimpl; }; @@ -84,7 +93,7 @@ class RawPointer class UniquePointer { public: - UniquePointer() : pimpl(new GenericImpl) + UniquePointer() : pimpl(std::make_unique()) { } @@ -93,6 +102,11 @@ class UniquePointer return this->pimpl->value; } + void setValue(int x) + { + this->pimpl->value = x; + } + private: std::unique_ptr pimpl; }; @@ -106,29 +120,31 @@ class UniquePointer class SutterPointer { public: - int getValue() const; - -private: - class Impl; - celero::Pimpl pimpl; -}; - -#include + int getValue() const + { + return this->pimpl->value; + } -class SutterPointer::Impl -{ -public: - Impl() : value(0) + void setValue(int x) { + this->pimpl->value = x; } - int value; +private: + class Impl + { + public: + Impl() : value(0) + { + } + + int value; + }; + + celero::Pimpl pimpl; }; -int SutterPointer::getValue() const -{ - return this->pimpl->value; -} +#include // // A basic test fixture for our tests to share. @@ -144,27 +160,49 @@ class DemoFixture : public celero::TestFixture }; static const int SamplesCount = 10000; -static const int IterationsCount = 10000; +static const int IterationsCount = 100000; // The number of iterations is very large because the operation is very quick. We want to // look at a large enough chunk of time to reduce the reliance on the resolution of the // clock. Then, do 30 samples of this large number of runs and keep the quickest. -BASELINE_F(CostOfPimpl, Baseline, DemoFixture, SamplesCount, IterationsCount) +BASELINE_F(CostOfPimplGet, Baseline, DemoFixture, SamplesCount, IterationsCount) { celero::DoNotOptimizeAway(noPtr.getValue()); } -BENCHMARK_F(CostOfPimpl, RawPtr, DemoFixture, SamplesCount, IterationsCount) +BENCHMARK_F(CostOfPimplGet, RawPtr, DemoFixture, SamplesCount, IterationsCount) { celero::DoNotOptimizeAway(rawPtr.getValue()); } -BENCHMARK_F(CostOfPimpl, UniquePtr, DemoFixture, SamplesCount, IterationsCount) +BENCHMARK_F(CostOfPimplGet, UniquePtr, DemoFixture, SamplesCount, IterationsCount) { celero::DoNotOptimizeAway(uniquePtr.getValue()); } -BENCHMARK_F(CostOfPimpl, SutterPtr, DemoFixture, SamplesCount, IterationsCount) +BENCHMARK_F(CostOfPimplGet, SutterPtr, DemoFixture, SamplesCount, IterationsCount) { celero::DoNotOptimizeAway(sutterPtr.getValue()); } + +// Set + +BASELINE_F(CostOfPimplSet, Baseline, DemoFixture, SamplesCount, IterationsCount) +{ + noPtr.setValue(5); +} + +BENCHMARK_F(CostOfPimplSet, RawPtr, DemoFixture, SamplesCount, IterationsCount) +{ + rawPtr.setValue(6); +} + +BENCHMARK_F(CostOfPimplSet, UniquePtr, DemoFixture, SamplesCount, IterationsCount) +{ + uniquePtr.setValue(7); +} + +BENCHMARK_F(CostOfPimplSet, SutterPtr, DemoFixture, SamplesCount, IterationsCount) +{ + sutterPtr.setValue(8); +} From bf2c7e98a02aac01578a1a65df7f281b9b4b193b Mon Sep 17 00:00:00 2001 From: John Farrier Date: Tue, 23 Feb 2021 19:16:12 -0500 Subject: [PATCH 05/11] #148 Added UDM to the output file Also remove Google Test submodule. --- .gitmodules | 3 - CMakeLists.txt | 3 +- README.md | 4 +- .../ExperimentCostSharedPtr/CMakeLists.txt | 6 -- googletest | 1 - src/ResultTable.cpp | 61 ++++++++++++++----- test/CMakeLists.txt | 6 +- 7 files changed, 52 insertions(+), 32 deletions(-) delete mode 100644 .gitmodules delete mode 160000 googletest diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 8cf8b5e..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "googletest"] - path = googletest - url = https://github.com/google/googletest.git diff --git a/CMakeLists.txt b/CMakeLists.txt index c665099..871161f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,9 +227,8 @@ add_subdirectory(experiments) if(CELERO_ENABLE_TESTS) set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - add_subdirectory(googletest) add_subdirectory(test) -endif() +endif() # ------------------------------------------------------------------------------ diff --git a/README.md b/README.md index 0d7e777..f71d055 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ### C++ Benchmarking Library -Copyright 2017-2019 John Farrier +Copyright 2017-2021 John Farrier Apache 2.0 License @@ -38,6 +38,8 @@ Celero has been successfully built on the following platforms during development - XCode v10.3 - XCode v11.0 +As of v2.7, Celero requres the developer to provide GoogleTest in order to build unit tests. We suggest using a package manager such as VCPKG or Conan to provide the latest version of the library. + #### Quality Control | Tooling | Status | diff --git a/experiments/ExperimentCostSharedPtr/CMakeLists.txt b/experiments/ExperimentCostSharedPtr/CMakeLists.txt index da1a0d2..6506256 100644 --- a/experiments/ExperimentCostSharedPtr/CMakeLists.txt +++ b/experiments/ExperimentCostSharedPtr/CMakeLists.txt @@ -16,12 +16,6 @@ # limitations under the License. # -# -# CMake Configuration -# - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) - # # Set the experiment's name here. Start it with a capital letter use camel case naming. # diff --git a/googletest b/googletest deleted file mode 160000 index cd17fa2..0000000 --- a/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cd17fa2abda2a2e4111cdabd62a87aea16835014 diff --git a/src/ResultTable.cpp b/src/ResultTable.cpp index 366dc66..776c24d 100644 --- a/src/ResultTable.cpp +++ b/src/ResultTable.cpp @@ -16,11 +16,11 @@ /// limitations under the License. /// +#include #include #include #include - -#include +#include #include #include @@ -34,7 +34,7 @@ using namespace celero; class celero::ResultTable::Impl { public: - Impl() : precision(5) + Impl() { } @@ -60,15 +60,7 @@ class celero::ResultTable::Impl this->ofs.open(x); - // Print the header for the table. - if(this->ofs.is_open() == true) - { - this->ofs << "Group,Experiment,Problem " - "Space,Samples,Iterations,Failure,Baseline,"; - this->ofs << "us/Iteration,Iterations/sec,Min (us),Mean (us),Max " - "(us),Variance,Standard Deviation,Skewness,Kurtosis,Z Score" - << std::endl; - } + this->hasWrittenHeader = false; } std::string format(double x) @@ -81,7 +73,8 @@ class celero::ResultTable::Impl } std::ofstream ofs; - const size_t precision; + const size_t precision{5}; + bool hasWrittenHeader{false}; }; ResultTable::ResultTable() : pimpl() @@ -113,13 +106,49 @@ void ResultTable::add(std::shared_ptr x) { if(this->pimpl->ofs.is_open() == true) { + if(this->pimpl->hasWrittenHeader == false) + { + // Print the header for the table. + this->pimpl->ofs << "Group,Experiment,Problem " + "Space,Samples,Iterations,Failure,Baseline,"; + + this->pimpl->ofs << "us/Iteration,Iterations/sec,Min (us),Mean (us),Max " + "(us),Variance,Standard Deviation,Skewness,Kurtosis,Z Score,"; + + // User Defined Metrics + const auto udmCollector = x->getUserDefinedMeasurements(); + for(const auto& entry : udmCollector->getAggregateValues()) + { + this->pimpl->ofs << entry.first << ","; + } + + // Purposefully flushing the buffer here. + this->pimpl->ofs << std::endl; + + this->pimpl->hasWrittenHeader = true; + } + + // Description this->pimpl->ofs << x->getExperiment()->getBenchmark()->getName() << "," << x->getExperiment()->getName() << "," << x->getProblemSpaceValue() << "," << x->getExperiment()->getSamples() << "," << x->getProblemSpaceIterations() << "," << x->getFailure() << ","; - this->pimpl->ofs << x->getBaselineMeasurement() << "," << x->getUsPerCall() << "," << x->getCallsPerSecond() << "," - << x->getTimeStatistics()->getMin() << "," << x->getTimeStatistics()->getMean() << "," << x->getTimeStatistics()->getMax() + // Measurements + this->pimpl->ofs << x->getBaselineMeasurement() << "," << x->getUsPerCall() << "," << x->getCallsPerSecond() << ","; + + // Statistics + this->pimpl->ofs << x->getTimeStatistics()->getMin() << "," << x->getTimeStatistics()->getMean() << "," << x->getTimeStatistics()->getMax() << "," << x->getTimeStatistics()->getVariance() << "," << x->getTimeStatistics()->getStandardDeviation() << "," << x->getTimeStatistics()->getSkewness() << "," << x->getTimeStatistics()->getKurtosis() << "," - << x->getTimeStatistics()->getZScore() << std::endl; + << x->getTimeStatistics()->getZScore() << ","; + + // User Defined Metrics + const auto udmCollector = x->getUserDefinedMeasurements(); + for(const auto& entry : udmCollector->getAggregateValues()) + { + this->pimpl->ofs << entry.second << ","; + } + + // Purposefully flushing the buffer here. + this->pimpl->ofs << std::endl; } } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 821aca1..e0fd9df 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -21,7 +21,7 @@ project(celero-test) add_executable(${PROJECT_NAME}) -add_dependencies(${PROJECT_NAME} gtest gtest_main) +find_package(GTest CONFIG REQUIRED) target_sources(${PROJECT_NAME} PRIVATE Archive.test.cpp @@ -54,8 +54,8 @@ CeleroSetDefaultCompilerOptions() target_link_libraries(${PROJECT_NAME} ${SYSLIBS} - gtest - gtest_main + GTest::gtest + GTest::gtest_main celero ) From 060ce52eb0a7af2ddff9df52899486d2ee86457f Mon Sep 17 00:00:00 2001 From: John Farrier <3240972+DigitalInBlue@users.noreply.github.com> Date: Tue, 23 Feb 2021 19:20:32 -0500 Subject: [PATCH 06/11] Create codeql-analysis.yml (#149) --- .github/workflows/codeql-analysis.yml | 67 +++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..4ab09b4 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,67 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ master, develop ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '31 20 * * 6' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + language: [ 'cpp' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 From f8f1d253f8391f8737a94165b3db9ff4ed8c57d3 Mon Sep 17 00:00:00 2001 From: John Farrier Date: Tue, 23 Feb 2021 20:13:48 -0500 Subject: [PATCH 07/11] Removed requirement for GTest in Travis.ci --- .travis.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 62c7674..c8b466c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,43 +52,43 @@ matrix: # Clang 3.9 - os: linux - env: LLVM_VERSION=3.9.0 CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1" + env: LLVM_VERSION=3.9.0 CMAKE_OPTIONS="" compiler: clang # Clang 5.0.1 - os: linux - env: LLVM_VERSION=5.0.1 CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1" + env: LLVM_VERSION=5.0.1 CMAKE_OPTIONS="" compiler: clang # Clang 7.0.0 - os: linux - env: LLVM_VERSION=7.0.0 CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1" + env: LLVM_VERSION=7.0.0 CMAKE_OPTIONS="" compiler: clang # Clang 8.0.0 - os: linux - env: LLVM_VERSION=7.0.0 CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1" + env: LLVM_VERSION=7.0.0 CMAKE_OPTIONS="" compiler: clang # GCC 6 - os: linux - env: COMPILER=g++-6 CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1" + env: COMPILER=g++-6 CMAKE_OPTIONS="" compiler: gcc # GCC 7 - os: linux - env: COMPILER=g++-7 CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1" + env: COMPILER=g++-7 CMAKE_OPTIONS="" compiler: gcc # GCC 8 - os: linux - env: COMPILER=g++-8 CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1" + env: COMPILER=g++-8 CMAKE_OPTIONS="" compiler: gcc # GCC 8 - os: linux name: Complete Build - env: COMPILER=g++-8 CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1 -DCELERO_ENABLE_EXPERIMENTS=1" + env: COMPILER=g++-8 CMAKE_OPTIONS="-DCELERO_ENABLE_EXPERIMENTS=1" compiler: gcc ########################################################################## @@ -97,7 +97,7 @@ matrix: # With debug mode - os: linux name: Debug Build - env: LLVM_VERSION=default CMAKE_OPTIONS="-DCELERO_ENABLE_TESTS=1 -DCMAKE_BUILD_TYPE=DEBUG" + env: LLVM_VERSION=default CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=DEBUG" compiler: clang # Temporarily broken within Travis.CI for CMake's update From 55a7cb166e692345586d1d55b6b263f8e2652325 Mon Sep 17 00:00:00 2001 From: John Farrier Date: Tue, 23 Feb 2021 20:24:48 -0500 Subject: [PATCH 08/11] #143 Added clarification to README.md on Doxygen. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f71d055..92de679 100644 --- a/README.md +++ b/README.md @@ -465,7 +465,7 @@ sudo cpupower frequency-set --governor powersave - Benchmarks should always be performed on Release builds. Never measure the performance of a Debug build and make changes based on the results. The (optimizing) compiler is your friend concerning code performance. - Accuracy is tied very closely to the total number of samples and the sample sizes. As a general rule, you should aim to execute your baseline code for about as long as your longest benchmark test. Further, it is helpful if all of the benchmark tests take about the same order of magnitude of execution time. (Don't compare a baseline that executed in 0.1 seconds with benchmarks that take 60 seconds and an hour, respectively.) -- Celero has Doxygen documentation of its API. +- Celero has Doxygen-style documentation of its API. (The Doxyfile is provided. The user must generate the documentation.) - Celero supports test fixtures for each baseline group. ## Celero Charts From b6f2b83785b8ba625d24198a3dadc61714e995b4 Mon Sep 17 00:00:00 2001 From: John Farrier Date: Tue, 23 Feb 2021 20:47:11 -0500 Subject: [PATCH 09/11] Code Cleanup --- include/celero/Experiment.h | 12 ++-- include/celero/ExperimentResult.h | 5 +- include/celero/JUnit.h | 1 + include/celero/Pimpl.h | 4 ++ include/celero/ResultTable.h | 4 ++ include/celero/Statistics.h | 12 +--- include/celero/TestFixture.h | 3 +- include/celero/TestVector.h | 6 +- include/celero/ThreadTestFixture.h | 3 + include/celero/Timer.h | 2 +- include/celero/UserDefinedMeasurement.h | 6 ++ src/Experiment.cpp | 80 ++++++++++++------------- src/ExperimentResult.cpp | 9 +-- 13 files changed, 78 insertions(+), 69 deletions(-) diff --git a/include/celero/Experiment.h b/include/celero/Experiment.h index bae01f3..900ce77 100644 --- a/include/celero/Experiment.h +++ b/include/celero/Experiment.h @@ -22,6 +22,7 @@ #include #include #include + #include namespace celero @@ -45,14 +46,16 @@ namespace celero /// /// explicit Experiment(std::weak_ptr benchmark, const std::string& name, uint64_t samples, uint64_t iterations, - uint64_t threads, - double baselineTarget); + uint64_t threads, double baselineTarget); /// /// \brief Default destructor. /// ~Experiment(); + Experiment(const Experiment&) = delete; + Experiment& operator=(Experiment const& other) = delete; + /// /// Gets a pointer to the owning Benchmark object. /// @@ -176,11 +179,6 @@ namespace celero /// Experiment(); - /// - /// Hide the copy constructor - /// - explicit Experiment(const celero::Experiment&); - /// /// /// \brief Pimpl Idiom diff --git a/include/celero/ExperimentResult.h b/include/celero/ExperimentResult.h index 77b2ed8..3caab8e 100644 --- a/include/celero/ExperimentResult.h +++ b/include/celero/ExperimentResult.h @@ -22,6 +22,7 @@ #include #include #include + #include namespace celero @@ -34,12 +35,12 @@ namespace celero /// /// \author John Farrier /// - class CELERO_EXPORT ExperimentResult + class CELERO_EXPORT ExperimentResult final { public: explicit ExperimentResult(Experiment* x); - ~ExperimentResult(); + ~ExperimentResult() = default; /// /// Gets a pointer to the owning experiment. diff --git a/include/celero/JUnit.h b/include/celero/JUnit.h index bb7534d..a982be0 100644 --- a/include/celero/JUnit.h +++ b/include/celero/JUnit.h @@ -21,6 +21,7 @@ #include #include + #include namespace celero diff --git a/include/celero/Pimpl.h b/include/celero/Pimpl.h index c330c69..a451df7 100644 --- a/include/celero/Pimpl.h +++ b/include/celero/Pimpl.h @@ -20,6 +20,7 @@ /// #include + #include namespace celero @@ -38,6 +39,9 @@ namespace celero { public: Pimpl(); + Pimpl(const Pimpl&) = delete; + Pimpl& operator=(Pimpl const& other) = delete; + // template Pimpl( Args&& ... ); template Pimpl(Arg1&&); diff --git a/include/celero/ResultTable.h b/include/celero/ResultTable.h index 470e624..55286c4 100644 --- a/include/celero/ResultTable.h +++ b/include/celero/ResultTable.h @@ -21,6 +21,7 @@ #include #include + #include namespace celero @@ -72,6 +73,9 @@ namespace celero /// ~ResultTable(); + ResultTable(const ResultTable&) = delete; + ResultTable& operator=(ResultTable const& other) = delete; + /// /// \brief Pimpl Idiom /// diff --git a/include/celero/Statistics.h b/include/celero/Statistics.h index f6189c6..8ca3ba7 100644 --- a/include/celero/Statistics.h +++ b/include/celero/Statistics.h @@ -51,14 +51,8 @@ namespace celero /// /// /// - Statistics(const Statistics& other) : - sampleSize(other.sampleSize), - M1(other.M1), - M2(other.M2), - M3(other.M3), - M4(other.M4), - min(other.min), - max(other.max) + Statistics(const Statistics& other) + : sampleSize(other.sampleSize), M1(other.M1), M2(other.M2), M3(other.M3), M4(other.M4), min(other.min), max(other.max) { } @@ -149,7 +143,7 @@ namespace celero this->sampleSize++; const auto delta = x - this->M1; - const auto delta_n = delta / this->sampleSize; + const auto delta_n = delta / static_cast(this->sampleSize); const auto delta_n2 = delta_n * delta_n; const auto term1 = delta * delta_n * n1; diff --git a/include/celero/TestFixture.h b/include/celero/TestFixture.h index ac07f5f..3bdcf95 100644 --- a/include/celero/TestFixture.h +++ b/include/celero/TestFixture.h @@ -21,6 +21,7 @@ #include #include + #include #include #include @@ -149,7 +150,7 @@ namespace celero /// /// Internal to Celero - /// + /// void setExperimentTime(uint64_t x); /// diff --git a/include/celero/TestVector.h b/include/celero/TestVector.h index 4bb6655..ee1ae02 100644 --- a/include/celero/TestVector.h +++ b/include/celero/TestVector.h @@ -22,6 +22,7 @@ #include #include #include + #include namespace celero @@ -36,6 +37,9 @@ namespace celero public: ~TestVector(); + TestVector(const TestVector&) = delete; + TestVector& operator=(TestVector const& other) = delete; + static TestVector& Instance(); void push_back(std::shared_ptr x); @@ -62,6 +66,6 @@ namespace celero /// Pimpl pimpl; }; -} +} // namespace celero #endif diff --git a/include/celero/ThreadTestFixture.h b/include/celero/ThreadTestFixture.h index ccf1d4c..7923f82 100644 --- a/include/celero/ThreadTestFixture.h +++ b/include/celero/ThreadTestFixture.h @@ -44,6 +44,9 @@ namespace celero /// virtual ~ThreadTestFixture(); + ThreadTestFixture(const ThreadTestFixture&) = delete; + ThreadTestFixture& operator=(ThreadTestFixture const& other) = delete; + /// /// Start threads before benchmark execution. /// diff --git a/include/celero/Timer.h b/include/celero/Timer.h index a2fc376..3bf7848 100644 --- a/include/celero/Timer.h +++ b/include/celero/Timer.h @@ -55,7 +55,7 @@ namespace celero /// constexpr double ConvertSystemTime(const uint64_t x) { - return x * celero::UsToSec; + return static_cast(x) * celero::UsToSec; } /// diff --git a/include/celero/UserDefinedMeasurement.h b/include/celero/UserDefinedMeasurement.h index 3c2e313..4ee25b4 100644 --- a/include/celero/UserDefinedMeasurement.h +++ b/include/celero/UserDefinedMeasurement.h @@ -20,6 +20,7 @@ /// #include + #include #include #include @@ -48,6 +49,11 @@ namespace celero class CELERO_EXPORT UserDefinedMeasurement { public: + /// + /// Expose the default destructor, but make it virtual to support inheritance. + /// + virtual ~UserDefinedMeasurement() = default; + /// /// \brief Must be implemented by the user. Must return a specification which aggregations the user wants to be computed. /// diff --git a/src/Experiment.cpp b/src/Experiment.cpp index 83d9206..a3f37fa 100644 --- a/src/Experiment.cpp +++ b/src/Experiment.cpp @@ -31,48 +31,48 @@ using namespace celero; class Experiment::Impl { public: - Impl() : - results(), - benchmark(), - factory(), - name(), - baselineUnit(0), - baselineTarget(0), - samples(0), - iterations(0), - threads(1), - totalRunTime(0), - isBaselineCase(false) + Impl() + : results(), + benchmark(), + factory(), + name(), + baselineUnit(0), + baselineTarget(0), + samples(0), + iterations(0), + threads(1), + totalRunTime(0), + isBaselineCase(false) { } - Impl(std::weak_ptr bm, const std::string& n, const uint64_t s, const uint64_t c, const uint64_t t, const double pBaselineTarget) : - results(), - benchmark(bm), - factory(), - name(n), - baselineUnit(0), - baselineTarget(pBaselineTarget), - samples(s), - iterations(c), - threads(t), - totalRunTime(0), - isBaselineCase(false) + Impl(std::weak_ptr bm, const std::string& n, const uint64_t s, const uint64_t c, const uint64_t t, const double pBaselineTarget) + : results(), + benchmark(bm), + factory(), + name(n), + baselineUnit(0), + baselineTarget(pBaselineTarget), + samples(s), + iterations(c), + threads(t), + totalRunTime(0), + isBaselineCase(false) { } - explicit Impl(std::weak_ptr bm) : - results(), - benchmark(bm), - factory(), - name(), - baselineUnit(0), - baselineTarget(0), - samples(0), - iterations(0), - threads(1), - totalRunTime(0), - isBaselineCase(false) + explicit Impl(std::weak_ptr bm) + : results(), + benchmark(bm), + factory(), + name(), + baselineUnit(0), + baselineTarget(0), + samples(0), + iterations(0), + threads(1), + totalRunTime(0), + isBaselineCase(false) { } @@ -119,12 +119,8 @@ Experiment::Experiment(std::weak_ptr benchmark) : pimpl(benchmark) } Experiment::Experiment(std::weak_ptr benchmark, const std::string& name, uint64_t samples, uint64_t iterations, uint64_t threads, - double baselineTarget) : - pimpl(benchmark, name, samples, iterations, threads, baselineTarget) -{ -} - -Experiment::Experiment(const Experiment&) + double baselineTarget) + : pimpl(benchmark, name, samples, iterations, threads, baselineTarget) { } diff --git a/src/ExperimentResult.cpp b/src/ExperimentResult.cpp index 4a2766b..a66a454 100644 --- a/src/ExperimentResult.cpp +++ b/src/ExperimentResult.cpp @@ -24,6 +24,7 @@ #include #include #include + #include #include @@ -68,10 +69,6 @@ ExperimentResult::ExperimentResult(Experiment* x) : pimpl(x) { } -ExperimentResult::~ExperimentResult() -{ -} - Experiment* ExperimentResult::getExperiment() const { return this->pimpl->parent; @@ -106,12 +103,12 @@ Statistics* ExperimentResult::getTimeStatistics() void ExperimentResult::addRunTimeSample(const uint64_t runTime) { - this->pimpl->statsTime.addSample(runTime); + this->pimpl->statsTime.addSample(static_cast(runTime)); } uint64_t ExperimentResult::getRunTime() const { - return this->pimpl->statsTime.getMin(); + return static_cast(this->pimpl->statsTime.getMin()); } double ExperimentResult::getUsPerCall() const From f6ccc0930ae14b80ed0cf86d24d949e243fbca20 Mon Sep 17 00:00:00 2001 From: John Farrier Date: Tue, 23 Feb 2021 20:53:40 -0500 Subject: [PATCH 10/11] Copyright Update 2021 --- include/celero/Archive.h | 2 +- include/celero/Benchmark.h | 2 +- include/celero/Celero.h | 2 +- include/celero/Console.h | 2 +- include/celero/Distribution.h | 2 +- include/celero/Exceptions.h | 2 +- include/celero/Executor.h | 2 +- include/celero/Experiment.h | 2 +- include/celero/ExperimentResult.h | 6 +++--- include/celero/Export.h | 2 +- include/celero/Factory.h | 2 +- include/celero/FileReader.h | 2 +- include/celero/GenericFactory.h | 2 +- include/celero/JUnit.h | 2 +- include/celero/Pimpl.h | 4 +--- include/celero/PimplImpl.h | 2 +- include/celero/Print.h | 2 +- include/celero/ResultTable.h | 2 +- include/celero/Statistics.h | 2 +- include/celero/TestFixture.h | 2 +- include/celero/TestVector.h | 2 +- include/celero/ThreadLocal.h | 2 +- include/celero/ThreadTestFixture.h | 2 +- include/celero/Timer.h | 2 +- include/celero/UserDefinedMeasurement.h | 2 +- include/celero/UserDefinedMeasurementCollector.h | 2 +- include/celero/UserDefinedMeasurementTemplate.h | 2 +- include/celero/Utilities.h | 2 +- src/Archive.cpp | 2 +- src/Benchmark.cpp | 2 +- src/Callbacks.cpp | 2 +- src/Celero.cpp | 3 ++- src/Console.cpp | 2 +- src/Distribution.cpp | 2 +- src/Executor.cpp | 3 ++- src/Experiment.cpp | 2 +- src/ExperimentResult.cpp | 6 +++++- src/JUnit.cpp | 3 ++- src/Memory.cpp | 2 +- src/Print.cpp | 5 +++-- src/ResultTable.cpp | 2 +- src/TestFixture.cpp | 2 +- src/TestVector.cpp | 2 +- src/ThreadTestFixture.cpp | 2 +- src/Timer.cpp | 2 +- src/UserDefinedMeasurementCollector.cpp | 2 +- src/Utilities.cpp | 2 +- 47 files changed, 58 insertions(+), 52 deletions(-) diff --git a/include/celero/Archive.h b/include/celero/Archive.h index 72ad9f0..475c98a 100644 --- a/include/celero/Archive.h +++ b/include/celero/Archive.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/Benchmark.h b/include/celero/Benchmark.h index 17585fe..4b9354e 100644 --- a/include/celero/Benchmark.h +++ b/include/celero/Benchmark.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/Celero.h b/include/celero/Celero.h index 9228621..dac372a 100644 --- a/include/celero/Celero.h +++ b/include/celero/Celero.h @@ -6,7 +6,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/Console.h b/include/celero/Console.h index f3c18bd..1c3a515 100644 --- a/include/celero/Console.h +++ b/include/celero/Console.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/Distribution.h b/include/celero/Distribution.h index 5ab01ba..f2e4e38 100644 --- a/include/celero/Distribution.h +++ b/include/celero/Distribution.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/Exceptions.h b/include/celero/Exceptions.h index 78ca817..cb041f7 100644 --- a/include/celero/Exceptions.h +++ b/include/celero/Exceptions.h @@ -4,7 +4,7 @@ /// /// \author Peter Azmanov /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/Executor.h b/include/celero/Executor.h index fef29de..1212e3b 100644 --- a/include/celero/Executor.h +++ b/include/celero/Executor.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/Experiment.h b/include/celero/Experiment.h index 900ce77..37071f1 100644 --- a/include/celero/Experiment.h +++ b/include/celero/Experiment.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/ExperimentResult.h b/include/celero/ExperimentResult.h index 3caab8e..ed298e8 100644 --- a/include/celero/ExperimentResult.h +++ b/include/celero/ExperimentResult.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. @@ -35,12 +35,12 @@ namespace celero /// /// \author John Farrier /// - class CELERO_EXPORT ExperimentResult final + class CELERO_EXPORT ExperimentResult { public: explicit ExperimentResult(Experiment* x); - ~ExperimentResult() = default; + ~ExperimentResult(); /// /// Gets a pointer to the owning experiment. diff --git a/include/celero/Export.h b/include/celero/Export.h index f3febf7..5540f26 100644 --- a/include/celero/Export.h +++ b/include/celero/Export.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/Factory.h b/include/celero/Factory.h index c485065..ff0d275 100644 --- a/include/celero/Factory.h +++ b/include/celero/Factory.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/FileReader.h b/include/celero/FileReader.h index f9b5f7b..9f2f826 100644 --- a/include/celero/FileReader.h +++ b/include/celero/FileReader.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/GenericFactory.h b/include/celero/GenericFactory.h index 776bf69..42d7a3a 100644 --- a/include/celero/GenericFactory.h +++ b/include/celero/GenericFactory.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/JUnit.h b/include/celero/JUnit.h index a982be0..533c62a 100644 --- a/include/celero/JUnit.h +++ b/include/celero/JUnit.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/Pimpl.h b/include/celero/Pimpl.h index a451df7..912a62f 100644 --- a/include/celero/Pimpl.h +++ b/include/celero/Pimpl.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. @@ -39,8 +39,6 @@ namespace celero { public: Pimpl(); - Pimpl(const Pimpl&) = delete; - Pimpl& operator=(Pimpl const& other) = delete; // template Pimpl( Args&& ... ); template diff --git a/include/celero/PimplImpl.h b/include/celero/PimplImpl.h index e145351..99df621 100644 --- a/include/celero/PimplImpl.h +++ b/include/celero/PimplImpl.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/Print.h b/include/celero/Print.h index a5be2a6..52a8184 100644 --- a/include/celero/Print.h +++ b/include/celero/Print.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/ResultTable.h b/include/celero/ResultTable.h index 55286c4..72a27f2 100644 --- a/include/celero/ResultTable.h +++ b/include/celero/ResultTable.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/Statistics.h b/include/celero/Statistics.h index 8ca3ba7..477c9f1 100644 --- a/include/celero/Statistics.h +++ b/include/celero/Statistics.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/TestFixture.h b/include/celero/TestFixture.h index 3bdcf95..b428221 100644 --- a/include/celero/TestFixture.h +++ b/include/celero/TestFixture.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/TestVector.h b/include/celero/TestVector.h index ee1ae02..262a453 100644 --- a/include/celero/TestVector.h +++ b/include/celero/TestVector.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/ThreadLocal.h b/include/celero/ThreadLocal.h index 12a10a2..c94d0e2 100644 --- a/include/celero/ThreadLocal.h +++ b/include/celero/ThreadLocal.h @@ -4,7 +4,7 @@ /// /// \author Ivan Shynkarenka /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/ThreadTestFixture.h b/include/celero/ThreadTestFixture.h index 7923f82..ee8e842 100644 --- a/include/celero/ThreadTestFixture.h +++ b/include/celero/ThreadTestFixture.h @@ -4,7 +4,7 @@ /// /// \author Ivan Shynkarenka /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/Timer.h b/include/celero/Timer.h index 3bf7848..79e19c2 100644 --- a/include/celero/Timer.h +++ b/include/celero/Timer.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/UserDefinedMeasurement.h b/include/celero/UserDefinedMeasurement.h index 4ee25b4..047af38 100644 --- a/include/celero/UserDefinedMeasurement.h +++ b/include/celero/UserDefinedMeasurement.h @@ -4,7 +4,7 @@ /// /// \author Lukas Barth /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/UserDefinedMeasurementCollector.h b/include/celero/UserDefinedMeasurementCollector.h index 89d807f..9b2cde4 100644 --- a/include/celero/UserDefinedMeasurementCollector.h +++ b/include/celero/UserDefinedMeasurementCollector.h @@ -4,7 +4,7 @@ /// /// \author Lukas Barth /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/UserDefinedMeasurementTemplate.h b/include/celero/UserDefinedMeasurementTemplate.h index 6a78e94..fc81a62 100644 --- a/include/celero/UserDefinedMeasurementTemplate.h +++ b/include/celero/UserDefinedMeasurementTemplate.h @@ -4,7 +4,7 @@ /// /// \author Lukas Barth, John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/include/celero/Utilities.h b/include/celero/Utilities.h index 93e3c53..214836b 100644 --- a/include/celero/Utilities.h +++ b/include/celero/Utilities.h @@ -4,7 +4,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/src/Archive.cpp b/src/Archive.cpp index b2e5db7..f5fe370 100644 --- a/src/Archive.cpp +++ b/src/Archive.cpp @@ -1,7 +1,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/src/Benchmark.cpp b/src/Benchmark.cpp index c90a123..c7a8ee6 100644 --- a/src/Benchmark.cpp +++ b/src/Benchmark.cpp @@ -1,7 +1,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/src/Callbacks.cpp b/src/Callbacks.cpp index 5edb46b..b0a125b 100644 --- a/src/Callbacks.cpp +++ b/src/Callbacks.cpp @@ -1,7 +1,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/src/Celero.cpp b/src/Celero.cpp index 5a3f54d..246dd95 100644 --- a/src/Celero.cpp +++ b/src/Celero.cpp @@ -1,7 +1,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ #include #include #include + #include #include #include diff --git a/src/Console.cpp b/src/Console.cpp index c8d372a..99297a6 100644 --- a/src/Console.cpp +++ b/src/Console.cpp @@ -1,7 +1,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/src/Distribution.cpp b/src/Distribution.cpp index 5fdd64e..abd572b 100644 --- a/src/Distribution.cpp +++ b/src/Distribution.cpp @@ -1,7 +1,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/src/Executor.cpp b/src/Executor.cpp index 4049e10..81397e9 100644 --- a/src/Executor.cpp +++ b/src/Executor.cpp @@ -1,7 +1,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ #include #include #include + #include #include #include diff --git a/src/Experiment.cpp b/src/Experiment.cpp index a3f37fa..507c008 100644 --- a/src/Experiment.cpp +++ b/src/Experiment.cpp @@ -1,7 +1,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/src/ExperimentResult.cpp b/src/ExperimentResult.cpp index a66a454..99682bf 100644 --- a/src/ExperimentResult.cpp +++ b/src/ExperimentResult.cpp @@ -1,7 +1,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. @@ -65,6 +65,10 @@ ExperimentResult::ExperimentResult() { } +ExperimentResult::~ExperimentResult() +{ +} + ExperimentResult::ExperimentResult(Experiment* x) : pimpl(x) { } diff --git a/src/JUnit.cpp b/src/JUnit.cpp index 9eb2e2e..80b87c9 100644 --- a/src/JUnit.cpp +++ b/src/JUnit.cpp @@ -1,7 +1,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ #include #include #include + #include #include #include diff --git a/src/Memory.cpp b/src/Memory.cpp index de3cfd4..68cd5ec 100644 --- a/src/Memory.cpp +++ b/src/Memory.cpp @@ -1,7 +1,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/src/Print.cpp b/src/Print.cpp index d8433ad..6f0d423 100644 --- a/src/Print.cpp +++ b/src/Print.cpp @@ -1,7 +1,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ #include #include #include + #include #include #include @@ -283,7 +284,7 @@ namespace celero celero::console::SetConsoleColor(temp_color); std::cout << PrintColumn(x->getBaselineMeasurement()); - celero::console::SetConsoleColor(celero::console::ConsoleColor::Default); + celero::console::SetConsoleColor(celero::console::ConsoleColor::Default); std::cout << " | "; celero::console::SetConsoleColor(temp_color); diff --git a/src/ResultTable.cpp b/src/ResultTable.cpp index 776c24d..96a10d8 100644 --- a/src/ResultTable.cpp +++ b/src/ResultTable.cpp @@ -1,7 +1,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/src/TestFixture.cpp b/src/TestFixture.cpp index a47d550..34a1424 100644 --- a/src/TestFixture.cpp +++ b/src/TestFixture.cpp @@ -1,7 +1,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/src/TestVector.cpp b/src/TestVector.cpp index 21203d3..db262b6 100644 --- a/src/TestVector.cpp +++ b/src/TestVector.cpp @@ -1,7 +1,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/src/ThreadTestFixture.cpp b/src/ThreadTestFixture.cpp index d8a17d7..d70dfa0 100644 --- a/src/ThreadTestFixture.cpp +++ b/src/ThreadTestFixture.cpp @@ -1,7 +1,7 @@ /// /// \author Ivan Shynkarenka /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/src/Timer.cpp b/src/Timer.cpp index 9f6e028..69a36a1 100644 --- a/src/Timer.cpp +++ b/src/Timer.cpp @@ -1,7 +1,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/src/UserDefinedMeasurementCollector.cpp b/src/UserDefinedMeasurementCollector.cpp index 68788c8..2bd4cb4 100644 --- a/src/UserDefinedMeasurementCollector.cpp +++ b/src/UserDefinedMeasurementCollector.cpp @@ -1,7 +1,7 @@ /// /// \author Lukas Barth /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. diff --git a/src/Utilities.cpp b/src/Utilities.cpp index 843029c..f3509b8 100644 --- a/src/Utilities.cpp +++ b/src/Utilities.cpp @@ -1,7 +1,7 @@ /// /// \author John Farrier /// -/// \copyright Copyright 2015, 2016, 2017, 2018. 2019 John Farrier +/// \copyright Copyright 2015-2021 John Farrier /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. From 577adb6cec3505de41ff1424eb5df5caf003fe6c Mon Sep 17 00:00:00 2001 From: John Farrier Date: Sat, 27 Feb 2021 08:59:48 -0500 Subject: [PATCH 11/11] General code cleanup. --- experiments/DemoTransform/DemoTransform.cpp | 22 +-- .../ExperimentCompressBools.cpp | 32 ++-- .../ExperimentCostSharedPtr/CMakeLists.txt | 8 +- .../ExperimentCostOfSharedPtr.cpp | 4 +- .../ExperimentParticles.cpp | 11 +- .../ExperimentSortingRandomInts.cpp | 11 +- .../ExperimentSortingRandomIntsUDM.cpp | 23 +-- include/celero/Celero.h | 160 +++++++++--------- include/celero/Executor.h | 2 +- .../celero/UserDefinedMeasurementTemplate.h | 5 +- src/Archive.cpp | 3 +- src/Executor.cpp | 18 +- src/ThreadTestFixture.cpp | 4 +- test/Timer.test.cpp | 2 +- 14 files changed, 150 insertions(+), 155 deletions(-) diff --git a/experiments/DemoTransform/DemoTransform.cpp b/experiments/DemoTransform/DemoTransform.cpp index 1c1a4ca..ca68b0e 100644 --- a/experiments/DemoTransform/DemoTransform.cpp +++ b/experiments/DemoTransform/DemoTransform.cpp @@ -41,12 +41,11 @@ constexpr int Multiple = 2112; class DemoTransformFixture : public celero::TestFixture { public: - DemoTransformFixture() { } - virtual std::vector getExperimentValues() const override + std::vector getExperimentValues() const override { std::vector problemSpaceValues; @@ -68,7 +67,7 @@ class DemoTransformFixture : public celero::TestFixture } /// Before each run, build a vector of random integers. - virtual void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override + void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override { this->arraySize = static_cast(experimentValue.Value); @@ -81,7 +80,7 @@ class DemoTransformFixture : public celero::TestFixture } /// After each run, clear the vector of random integers. - virtual void tearDown() override + void tearDown() override { this->arrayIn.clear(); this->arrayOut.clear(); @@ -102,18 +101,17 @@ BASELINE_F(DemoTransform, ForLoop, DemoTransformFixture, 30, 10000) } BASELINE_FIXED_F(DemoTransform, FixedTime, DemoTransformFixture, 1, 100) -{ } +{ +} BENCHMARK_F(DemoTransform, StdTransform, DemoTransformFixture, 30, 10000) { - std::transform(this->arrayIn.begin(), this->arrayIn.end(), this->arrayOut.begin(), - std::bind1st(std::multiplies(), Multiple)); + std::transform(this->arrayIn.begin(), this->arrayIn.end(), this->arrayOut.begin(), std::bind1st(std::multiplies(), Multiple)); } BENCHMARK_F(DemoTransform, StdTransformLambda, DemoTransformFixture, 30, 10000) { - std::transform(this->arrayIn.begin(), this->arrayIn.end(), this->arrayOut.begin(), - [](int in) -> int { return in * Multiple; }); + std::transform(this->arrayIn.begin(), this->arrayIn.end(), this->arrayOut.begin(), [](int in) -> int { return in * Multiple; }); } BENCHMARK_F(DemoTransform, SelfForLoop, DemoTransformFixture, 30, 10000) @@ -126,12 +124,10 @@ BENCHMARK_F(DemoTransform, SelfForLoop, DemoTransformFixture, 30, 10000) BENCHMARK_F(DemoTransform, SelfStdTransform, DemoTransformFixture, 30, 10000) { - std::transform(this->arrayIn.begin(), this->arrayIn.end(), this->arrayIn.begin(), - std::bind1st(std::multiplies(), Multiple)); + std::transform(this->arrayIn.begin(), this->arrayIn.end(), this->arrayIn.begin(), std::bind1st(std::multiplies(), Multiple)); } BENCHMARK_F(DemoTransform, SelfStdTransformLambda, DemoTransformFixture, 30, 10000) { - std::transform(this->arrayIn.begin(), this->arrayIn.end(), this->arrayIn.begin(), - [](int in) -> int { return in * Multiple; }); + std::transform(this->arrayIn.begin(), this->arrayIn.end(), this->arrayIn.begin(), [](int in) -> int { return in * Multiple; }); } diff --git a/experiments/ExperimentCompressBools/ExperimentCompressBools.cpp b/experiments/ExperimentCompressBools/ExperimentCompressBools.cpp index e91aec6..f3421dd 100644 --- a/experiments/ExperimentCompressBools/ExperimentCompressBools.cpp +++ b/experiments/ExperimentCompressBools/ExperimentCompressBools.cpp @@ -1,13 +1,9 @@ // Original code at: https://github.com/fenbf/benchmarkLibsTest -#pragma warning(push) -#pragma warning(disable : 4251) // warning C4251: celero::Result::pimpl': class 'celero::Pimpl' needs to have dll-interface to - // be used by clients of class 'celero::Result' #include -#pragma warning(pop) - #include #include + #include #include #include @@ -53,7 +49,7 @@ class MyExperimentValue : public celero::TestFixture::ExperimentValue class CompressBoolsFixture : public celero::TestFixture { public: - virtual std::vector getExperimentValues() const override + std::vector getExperimentValues() const override { std::vector problemSpace; @@ -75,7 +71,7 @@ class CompressBoolsFixture : public celero::TestFixture } /// Before each run, build a vector of random integers. - virtual void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override + void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override { this->arrayLength = static_cast(experimentValue.Value); this->inputValues.reset(new int[arrayLength]); @@ -108,13 +104,13 @@ class CompressBoolsFixture : public celero::TestFixture class NoPackingFixture : public CompressBoolsFixture { public: - virtual void setUp(const celero::TestFixture::ExperimentValue& x) override + void setUp(const celero::TestFixture::ExperimentValue& x) override { CompressBoolsFixture::setUp(x); this->outputValues.reset(new bool[static_cast(arrayLength)]); } - virtual void tearDown() override + void tearDown() override { for(size_t i = 0; i < arrayLength; ++i) { @@ -136,7 +132,7 @@ BASELINE_F(CompressBoolsTest, NoPackingVersion, NoPackingFixture, SamplesCount, class StdBitsetFixture : public CompressBoolsFixture { public: - virtual void tearDown() override + void tearDown() override { for(size_t i = 0; i < this->arrayLength; ++i) { @@ -160,13 +156,13 @@ BENCHMARK_F(CompressBoolsTest, StdBitset, StdBitsetFixture, SamplesCount, Iterat class StdVectorFixture : public CompressBoolsFixture { public: - virtual void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override + void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override { CompressBoolsFixture::setUp(experimentValue); this->outputVector.resize(static_cast(experimentValue.Value)); } - virtual void tearDown() override + void tearDown() override { for(size_t i = 0; i < arrayLength; ++i) { @@ -192,7 +188,7 @@ class ManualVersionFixture : public CompressBoolsFixture { } - virtual void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override + void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override { CompressBoolsFixture::setUp(experimentValue); @@ -202,7 +198,7 @@ class ManualVersionFixture : public CompressBoolsFixture this->outputValues.reset(new uint8_t[this->numBytes]); } - virtual void tearDown() override + void tearDown() override { for(size_t i = 0; i < this->arrayLength; ++i) { @@ -311,7 +307,7 @@ struct bool8 class PackedStructFixture : public CompressBoolsFixture { public: - virtual void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override + void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override { CompressBoolsFixture::setUp(experimentValue); @@ -320,7 +316,7 @@ class PackedStructFixture : public CompressBoolsFixture this->outputValues.reset(new bool8[numBytes]); } - virtual void tearDown() override + void tearDown() override { for(size_t i = 0; i < arrayLength; ++i) { @@ -467,7 +463,7 @@ BENCHMARK_F(CompressBoolsTest, WithOpenMP, ManualVersionFixture, SamplesCount, I class SimdVersionFixture : public CompressBoolsFixture { public: - virtual void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override + void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override { CompressBoolsFixture::setUp(experimentValue); @@ -482,7 +478,7 @@ class SimdVersionFixture : public CompressBoolsFixture } } - virtual void tearDown() override + void tearDown() override { for(size_t i = 0; i < this->arrayLength; ++i) { diff --git a/experiments/ExperimentCostSharedPtr/CMakeLists.txt b/experiments/ExperimentCostSharedPtr/CMakeLists.txt index 6506256..8d19bf2 100644 --- a/experiments/ExperimentCostSharedPtr/CMakeLists.txt +++ b/experiments/ExperimentCostSharedPtr/CMakeLists.txt @@ -21,23 +21,17 @@ # SET(PROJECT_NAME CeleroExperiment-CostOfSharedPtr) - # - # Add Header Files - # - set(TARGET_H - ) - # # Add Sources # set(TARGET_SRC ExperimentCostOfSharedPtr.cpp + osg_ref_ptr.h ) # Broiler Plate: Assign the src and headers to the executable. add_executable(${PROJECT_NAME} ${TARGET_SRC} - ${TARGET_H} ) # Broiler Plate: Celero Project Dependencies diff --git a/experiments/ExperimentCostSharedPtr/ExperimentCostOfSharedPtr.cpp b/experiments/ExperimentCostSharedPtr/ExperimentCostOfSharedPtr.cpp index d2cc1be..a62d094 100644 --- a/experiments/ExperimentCostSharedPtr/ExperimentCostOfSharedPtr.cpp +++ b/experiments/ExperimentCostSharedPtr/ExperimentCostOfSharedPtr.cpp @@ -1,12 +1,12 @@ #include #include -#include "osg_ref_ptr.h" - #include #include #include +#include "osg_ref_ptr.h" + /// /// This is the main(int argc, char** argv) for the entire celero program. /// You can write your own, or use this macro to insert the standard one into the project. diff --git a/experiments/ExperimentParticles/ExperimentParticles.cpp b/experiments/ExperimentParticles/ExperimentParticles.cpp index b9eae85..5470940 100644 --- a/experiments/ExperimentParticles/ExperimentParticles.cpp +++ b/experiments/ExperimentParticles/ExperimentParticles.cpp @@ -1,6 +1,7 @@ // Original code at: https://github.com/fenbf/benchmarkLibsTest #include + #include "Particles.h" CELERO_MAIN; @@ -8,7 +9,7 @@ CELERO_MAIN; class ParticlesFixture : public celero::TestFixture { public: - virtual std::vector getExperimentValues() const override + std::vector getExperimentValues() const override { std::vector problemSpace; const auto totalNumberOfTests = 10; @@ -28,7 +29,7 @@ class ParticlesObjVectorFixture : public ParticlesFixture { public: /// Before each run, build a vector of random integers. - virtual void setUp(const celero::TestFixture::ExperimentValue& x) override + void setUp(const celero::TestFixture::ExperimentValue& x) override { this->particles = std::vector(x.Value); @@ -39,7 +40,7 @@ class ParticlesObjVectorFixture : public ParticlesFixture } /// After each run, clear the vector - virtual void tearDown() override + void tearDown() override { this->particles.clear(); } @@ -72,7 +73,7 @@ class ParticlesPtrVectorFixture : public ParticlesFixture } /// Before each run, build a vector of random integers. - virtual void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override + void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override { this->particles = std::vector>(experimentValue.Value); @@ -102,7 +103,7 @@ class ParticlesPtrVectorFixture : public ParticlesFixture } /// After each run, clear the vector - virtual void tearDown() override + void tearDown() override { this->particles.clear(); } diff --git a/experiments/ExperimentSortingRandomInts/ExperimentSortingRandomInts.cpp b/experiments/ExperimentSortingRandomInts/ExperimentSortingRandomInts.cpp index e8f85c5..9e1dabc 100644 --- a/experiments/ExperimentSortingRandomInts/ExperimentSortingRandomInts.cpp +++ b/experiments/ExperimentSortingRandomInts/ExperimentSortingRandomInts.cpp @@ -1,4 +1,5 @@ #include + #include #ifndef _WIN32 @@ -40,7 +41,7 @@ class SortFixture : public celero::TestFixture { } - virtual std::vector getExperimentValues() const override + std::vector getExperimentValues() const override { std::vector problemSpace; @@ -55,14 +56,14 @@ class SortFixture : public celero::TestFixture } /// Before each sample, build a vector of random integers. - virtual void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override + void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override { this->arraySize = experimentValue.Value; this->array.resize(this->arraySize); } // Before each iteration - virtual void onExperimentStart(const celero::TestFixture::ExperimentValue&) override + void onExperimentStart(const celero::TestFixture::ExperimentValue&) override { for(int i = 0; i < this->arraySize; i++) { @@ -71,14 +72,14 @@ class SortFixture : public celero::TestFixture } // After each iteration - virtual void onExperimentEnd() override + void onExperimentEnd() override { /// After each iteration, clear the vector of random integers. this->array.clear(); } // After each sample - virtual void tearDown() override + void tearDown() override { } diff --git a/experiments/ExperimentSortingRandomIntsUDM/ExperimentSortingRandomIntsUDM.cpp b/experiments/ExperimentSortingRandomIntsUDM/ExperimentSortingRandomIntsUDM.cpp index 8df7296..c9f28e4 100644 --- a/experiments/ExperimentSortingRandomIntsUDM/ExperimentSortingRandomIntsUDM.cpp +++ b/experiments/ExperimentSortingRandomIntsUDM/ExperimentSortingRandomIntsUDM.cpp @@ -1,4 +1,5 @@ #include + #include #include #include @@ -98,28 +99,28 @@ class SortFixture : public celero::TestFixture public: class CopyCountUDM : public celero::UserDefinedMeasurementTemplate { - virtual std::string getName() const override + std::string getName() const override { return "Copies"; } // Turn off some of the output reporting. - virtual bool reportStandardDeviation() const override + bool reportStandardDeviation() const override { return false; } - virtual bool reportSkewness() const override + bool reportSkewness() const override { return false; } - virtual bool reportKurtosis() const override + bool reportKurtosis() const override { return false; } - virtual bool reportZScore() const override + bool reportZScore() const override { return false; } @@ -129,7 +130,7 @@ class SortFixture : public celero::TestFixture { } - virtual std::vector getExperimentValues() const override + std::vector getExperimentValues() const override { std::vector problemSpace; @@ -144,13 +145,13 @@ class SortFixture : public celero::TestFixture } /// Before each sample, build a vector of random integers. - virtual void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override + void setUp(const celero::TestFixture::ExperimentValue& experimentValue) override { this->arraySize = experimentValue.Value; } // Before each iteration - virtual void onExperimentStart(const celero::TestFixture::ExperimentValue&) override + void onExperimentStart(const celero::TestFixture::ExperimentValue&) override { this->array.resize(this->arraySize); CopyCountingInt::resetCount(); @@ -161,11 +162,11 @@ class SortFixture : public celero::TestFixture } } - virtual void tearDown() override + void tearDown() override { } - virtual void onExperimentEnd() override + void onExperimentEnd() override { /// After each iteration, clear the vector of random integers. this->array.clear(); @@ -174,7 +175,7 @@ class SortFixture : public celero::TestFixture CopyCountingInt::resetCount(); } - virtual std::vector> getUserDefinedMeasurements() const override + std::vector> getUserDefinedMeasurements() const override { return {this->copyCountUDM}; } diff --git a/include/celero/Celero.h b/include/celero/Celero.h index dac372a..69aac02 100644 --- a/include/celero/Celero.h +++ b/include/celero/Celero.h @@ -60,8 +60,8 @@ namespace celero /// \returns a pointer to a Benchmark instance representing the given test. /// CELERO_EXPORT std::shared_ptr RegisterTest(const char* groupName, const char* benchmarkName, const uint64_t samples, - const uint64_t iterations, const uint64_t threads, - std::shared_ptr experimentFactory, const double target = -1); + const uint64_t iterations, const uint64_t threads, + std::shared_ptr experimentFactory, const double target = -1); /// /// \brief Adds a new test baseline to the list of test baseliness to be executed. @@ -103,11 +103,11 @@ namespace celero /// /// \brief A macro to build the most basic main() required to run the benchmark tests. /// -#define CELERO_MAIN \ - int main(int argc, char** argv) \ - { \ - celero::Run(argc, argv); \ - return 0; \ +#define CELERO_MAIN \ + int main(int argc, char** argv) \ + { \ + celero::Run(argc, argv); \ + return 0; \ } /// @@ -122,25 +122,25 @@ namespace celero /// /// A macro to create a class of a unique name which can be used to register and execute a benchmark test. /// -#define BENCHMARK_IMPL(groupName, benchmarkName, fixtureName, samples, iterations, threads) \ - class BENCHMARK_CLASS_NAME(groupName, benchmarkName) : public fixtureName \ - { \ - public: \ - BENCHMARK_CLASS_NAME(groupName, benchmarkName)() : fixtureName() \ - { \ - } \ - \ - protected: \ - virtual void UserBenchmark() override; \ - \ - private: \ - static const std::shared_ptr<::celero::Benchmark> info; \ - }; \ - \ - const std::shared_ptr<::celero::Benchmark> BENCHMARK_CLASS_NAME(groupName, benchmarkName)::info = \ - ::celero::RegisterTest(#groupName, #benchmarkName, samples, iterations, threads, \ - std::make_shared<::celero::GenericFactory>()); \ - \ +#define BENCHMARK_IMPL(groupName, benchmarkName, fixtureName, samples, iterations, threads) \ + class BENCHMARK_CLASS_NAME(groupName, benchmarkName) : public fixtureName \ + { \ + public: \ + BENCHMARK_CLASS_NAME(groupName, benchmarkName)() : fixtureName() \ + { \ + } \ + \ + protected: \ + void UserBenchmark() override; \ + \ + private: \ + static const std::shared_ptr<::celero::Benchmark> info; \ + }; \ + \ + const std::shared_ptr<::celero::Benchmark> BENCHMARK_CLASS_NAME(groupName, benchmarkName)::info = \ + ::celero::RegisterTest(#groupName, #benchmarkName, samples, iterations, threads, \ + std::make_shared<::celero::GenericFactory>()); \ + \ void BENCHMARK_CLASS_NAME(groupName, benchmarkName)::UserBenchmark() /// @@ -148,25 +148,25 @@ namespace celero /// /// A macro to create a class of a unique name which can be used to register and execute a benchmark test. /// -#define BENCHMARK_TEST_IMPL(groupName, benchmarkName, fixtureName, samples, iterations, threads, target) \ - class BENCHMARK_CLASS_NAME(groupName, benchmarkName) : public fixtureName \ - { \ - public: \ - BENCHMARK_CLASS_NAME(groupName, benchmarkName)() : fixtureName() \ - { \ - } \ - \ - protected: \ - virtual void UserBenchmark() override; \ - \ - private: \ - static const std::shared_ptr<::celero::Benchmark> info; \ - }; \ - \ - const std::shared_ptr<::celero::Benchmark> BENCHMARK_CLASS_NAME(groupName, benchmarkName)::info = \ - ::celero::RegisterTest(#groupName, #benchmarkName, samples, iterations, threads, \ - std::make_shared<::celero::GenericFactory>(), target); \ - \ +#define BENCHMARK_TEST_IMPL(groupName, benchmarkName, fixtureName, samples, iterations, threads, target) \ + class BENCHMARK_CLASS_NAME(groupName, benchmarkName) : public fixtureName \ + { \ + public: \ + BENCHMARK_CLASS_NAME(groupName, benchmarkName)() : fixtureName() \ + { \ + } \ + \ + protected: \ + void UserBenchmark() override; \ + \ + private: \ + static const std::shared_ptr<::celero::Benchmark> info; \ + }; \ + \ + const std::shared_ptr<::celero::Benchmark> BENCHMARK_CLASS_NAME(groupName, benchmarkName)::info = \ + ::celero::RegisterTest(#groupName, #benchmarkName, samples, iterations, threads, \ + std::make_shared<::celero::GenericFactory>(), target); \ + \ void BENCHMARK_CLASS_NAME(groupName, benchmarkName)::UserBenchmark() /// @@ -176,7 +176,7 @@ namespace celero /// /// Using the BENCHMARK_ macro, this effectivly fills in a class's UserBenchmark() function. /// -#define BENCHMARK_F(groupName, benchmarkName, fixtureName, samples, iterations) \ +#define BENCHMARK_F(groupName, benchmarkName, fixtureName, samples, iterations) \ BENCHMARK_IMPL(groupName, benchmarkName, fixtureName, samples, iterations, 1) /// @@ -186,7 +186,7 @@ namespace celero /// /// Using the BENCHMARK_ macro, this effectivly fills in a class's UserBenchmark() function. /// -#define BENCHMARK_T(groupName, benchmarkName, fixtureName, samples, iterations, threads) \ +#define BENCHMARK_T(groupName, benchmarkName, fixtureName, samples, iterations, threads) \ BENCHMARK_IMPL(groupName, benchmarkName, fixtureName, samples, iterations, threads) /// @@ -196,7 +196,7 @@ namespace celero /// /// Using the BENCHMARK_ macro, this effectivly fills in a class's UserBenchmark() function. /// -#define BENCHMARK_TEST_F(groupName, benchmarkName, fixtureName, samples, iterations, target) \ +#define BENCHMARK_TEST_F(groupName, benchmarkName, fixtureName, samples, iterations, target) \ BENCHMARK_TEST_IMPL(groupName, benchmarkName, fixtureName, samples, iterations, 1, target) /// @@ -206,7 +206,7 @@ namespace celero /// /// Using the BENCHMARK_ macro, this effectivly fills in a class's UserBenchmark() function. /// -#define BENCHMARK_TEST_T(groupName, benchmarkName, fixtureName, samples, iterations, threads, target) \ +#define BENCHMARK_TEST_T(groupName, benchmarkName, fixtureName, samples, iterations, threads, target) \ BENCHMARK_TEST_IMPL(groupName, benchmarkName, fixtureName, samples, iterations, threads, target) /// @@ -216,7 +216,7 @@ namespace celero /// /// Using the BENCHMARK_ macro, this effectivly fills in a class's UserBenchmark() function. /// -#define BENCHMARK(groupName, benchmarkName, samples, iterations) \ +#define BENCHMARK(groupName, benchmarkName, samples, iterations) \ BENCHMARK_IMPL(groupName, benchmarkName, ::celero::TestFixture, samples, iterations, 1) /// @@ -226,7 +226,7 @@ namespace celero /// /// Using the BENCHMARK_ macro, this effectivly fills in a class's UserBenchmark() function. /// -#define BENCHMARK_TEST(groupName, benchmarkName, samples, iterations, target) \ +#define BENCHMARK_TEST(groupName, benchmarkName, samples, iterations, target) \ BENCHMARK_TEST_IMPL(groupName, benchmarkName, ::celero::TestFixture, samples, iterations, 1, target) /// @@ -241,29 +241,29 @@ namespace celero /// /// A macro to create a class of a unique name which can be used to register and execute a baseline benchmark test. /// -#define BASELINE_IMPL(groupName, baselineName, fixtureName, samples, iterations, threads, useconds) \ - class BASELINE_CLASS_NAME(groupName, baselineName) : public fixtureName \ - { \ - public: \ - BASELINE_CLASS_NAME(groupName, baselineName)() : fixtureName() \ - { \ - } \ - \ - protected: \ - virtual void UserBenchmark() override; \ - virtual uint64_t HardCodedMeasurement() const override \ - { \ - return uint64_t(useconds); \ - } \ - \ - private: \ - static const std::shared_ptr<::celero::Benchmark> info; \ - }; \ - \ - const std::shared_ptr<::celero::Benchmark> BASELINE_CLASS_NAME(groupName, baselineName)::info = \ - ::celero::RegisterBaseline(#groupName, #baselineName, samples, iterations, threads, \ - std::make_shared<::celero::GenericFactory>()); \ - \ +#define BASELINE_IMPL(groupName, baselineName, fixtureName, samples, iterations, threads, useconds) \ + class BASELINE_CLASS_NAME(groupName, baselineName) : public fixtureName \ + { \ + public: \ + BASELINE_CLASS_NAME(groupName, baselineName)() : fixtureName() \ + { \ + } \ + \ + protected: \ + void UserBenchmark() override; \ + uint64_t HardCodedMeasurement() const override \ + { \ + return uint64_t(useconds); \ + } \ + \ + private: \ + static const std::shared_ptr<::celero::Benchmark> info; \ + }; \ + \ + const std::shared_ptr<::celero::Benchmark> BASELINE_CLASS_NAME(groupName, baselineName)::info = \ + ::celero::RegisterBaseline(#groupName, #baselineName, samples, iterations, threads, \ + std::make_shared<::celero::GenericFactory>()); \ + \ void BASELINE_CLASS_NAME(groupName, baselineName)::UserBenchmark() /// @@ -273,7 +273,7 @@ namespace celero /// /// Using the BASELINE_ macro, this effectivly fills in a class's UserBenchmark() function. /// -#define BASELINE_F(groupName, baselineName, fixtureName, samples, iterations) \ +#define BASELINE_F(groupName, baselineName, fixtureName, samples, iterations) \ BASELINE_IMPL(groupName, baselineName, fixtureName, samples, iterations, 1, 0) /// @@ -283,7 +283,7 @@ namespace celero /// /// Using the BASELINE_ macro, this effectivly fills in a class's UserBenchmark() function. /// -#define BASELINE_T(groupName, baselineName, fixtureName, samples, iterations, threads) \ +#define BASELINE_T(groupName, baselineName, fixtureName, samples, iterations, threads) \ BASELINE_IMPL(groupName, baselineName, fixtureName, samples, iterations, threads, 0) /// @@ -293,7 +293,7 @@ namespace celero /// /// Using the BASELINE_ macro, this effectivly fills in a class's UserBenchmark() function. /// -#define BASELINE(groupName, baselineName, samples, iterations) \ +#define BASELINE(groupName, baselineName, samples, iterations) \ BASELINE_IMPL(groupName, baselineName, ::celero::TestFixture, samples, iterations, 1, 0) /// @@ -305,11 +305,11 @@ namespace celero /// /// Using the BASELINE_ macro, this effectivly fills in a class's UserBenchmark() function. /// -#define BASELINE_FIXED(groupName, baselineName, iterations, useconds) \ +#define BASELINE_FIXED(groupName, baselineName, iterations, useconds) \ BASELINE_IMPL(groupName, baselineName, ::celero::TestFixture, 1, iterations, 1, useconds) -#define BASELINE_FIXED_F(groupName, baselineName, fixtureName, iterations, useconds) \ +#define BASELINE_FIXED_F(groupName, baselineName, fixtureName, iterations, useconds) \ BASELINE_IMPL(groupName, baselineName, fixtureName, 1, iterations, 1, useconds) -#define BASELINE_FIXED_T(groupName, baselineName, fixtureName, iterations, threads, useconds) \ +#define BASELINE_FIXED_T(groupName, baselineName, fixtureName, iterations, threads, useconds) \ BASELINE_IMPL(groupName, baselineName, fixtureName, 1, iterations, threads, useconds) #endif diff --git a/include/celero/Executor.h b/include/celero/Executor.h index 1212e3b..fbc5a08 100644 --- a/include/celero/Executor.h +++ b/include/celero/Executor.h @@ -41,7 +41,7 @@ namespace celero /// /// Run a specific benchmark's baseline. /// - CELERO_EXPORT void RunBaseline(std::shared_ptr x); + CELERO_EXPORT bool RunBaseline(std::shared_ptr x); /// /// Run all experiments registered within the final application. diff --git a/include/celero/UserDefinedMeasurementTemplate.h b/include/celero/UserDefinedMeasurementTemplate.h index fc81a62..4d30d0a 100644 --- a/include/celero/UserDefinedMeasurementTemplate.h +++ b/include/celero/UserDefinedMeasurementTemplate.h @@ -21,6 +21,7 @@ #include #include + #include #include @@ -52,7 +53,7 @@ namespace celero /// /// \brief Must be implemented by the user. Must return a specification which aggregations the user wants to be computed. /// - virtual UDMAggregationTable getAggregationInfo() const override + UDMAggregationTable getAggregationInfo() const override { UDMAggregationTable table; @@ -115,7 +116,7 @@ namespace celero /// /// Preserve measurements within a group/experiment/problem space set. /// - virtual void merge(const UserDefinedMeasurement* const x) override + void merge(const UserDefinedMeasurement* const x) override { const auto toMerge = dynamic_cast* const>(x); this->stats += toMerge->stats; diff --git a/src/Archive.cpp b/src/Archive.cpp index f5fe370..a7fb239 100644 --- a/src/Archive.cpp +++ b/src/Archive.cpp @@ -21,6 +21,7 @@ #include #include #include + #include #include #include @@ -396,7 +397,7 @@ void Archive::save() } else { - std::cerr << "Celero: Could not open result output file: \"" << this->pimpl->fileName << "\"" << std::endl; + std::cerr << "ERROR: Celero could not open result output file: \"" << this->pimpl->fileName << "\"." << std::endl; } } } diff --git a/src/Executor.cpp b/src/Executor.cpp index 81397e9..893f8ed 100644 --- a/src/Executor.cpp +++ b/src/Executor.cpp @@ -144,7 +144,7 @@ bool ExecuteProblemSpace(std::shared_ptr r) } else { - std::cerr << "Celero: Test \"" << r->getExperiment()->getBenchmark()->getName() << "::" << r->getExperiment()->getName() + std::cerr << "ERROR: Celero Test \"" << r->getExperiment()->getBenchmark()->getName() << "::" << r->getExperiment()->getName() << "\" must have at least 1 sample." << std::endl; return false; } @@ -178,11 +178,11 @@ void executor::RunAllExperiments() } } -void executor::RunBaseline(std::shared_ptr bmark) +bool executor::RunBaseline(std::shared_ptr bmark) { if(bmark == nullptr) { - return; + return false; } auto baselineExperiment = bmark->getBaseline(); @@ -245,9 +245,11 @@ void executor::RunBaseline(std::shared_ptr bmark) } else { - std::cerr << "No Baseline case defined for \"" + bmark->getName() + "\". Exiting."; - std::exit(EXIT_FAILURE); + std::cerr << "ERROR: No Baseline case defined for \"" + bmark->getName() + "\".\n"; + return false; } + + return true; } void executor::RunExperiments(std::shared_ptr bmark) @@ -373,8 +375,10 @@ void executor::Run(std::shared_ptr e) void executor::Run(std::shared_ptr bmark) { - executor::RunBaseline(bmark); - executor::RunExperiments(bmark); + if(executor::RunBaseline(bmark) == true) + { + executor::RunExperiments(bmark); + } } void executor::Run(const std::string& benchmarkName) diff --git a/src/ThreadTestFixture.cpp b/src/ThreadTestFixture.cpp index d70dfa0..bf61e5e 100644 --- a/src/ThreadTestFixture.cpp +++ b/src/ThreadTestFixture.cpp @@ -66,7 +66,7 @@ void ThreadTestFixture::startThreads(uint64_t threads, uint64_t iterations) } catch(std::system_error& e) { - std::cerr << "Exception. Error Code: " << e.code() << ", " << e.what() << std::endl; + std::cerr << "ERROR: Exception. Error Code: " << e.code() << ", " << e.what() << std::endl; } } } @@ -85,7 +85,7 @@ void ThreadTestFixture::stopThreads() } catch(std::system_error& e) { - std::cerr << "Exception. Error Code: " << e.code() << ", " << e.what() << std::endl; + std::cerr << "ERROR: Exception. Error Code: " << e.code() << ", " << e.what() << std::endl; } } }; diff --git a/test/Timer.test.cpp b/test/Timer.test.cpp index d16576f..c16b1d2 100644 --- a/test/Timer.test.cpp +++ b/test/Timer.test.cpp @@ -22,7 +22,7 @@ TEST(Timer, GetSystemTime) { const auto time = celero::timer::GetSystemTime(); - EXPECT_EQ(time, 0); + EXPECT_NE(time, 0); } TEST(Timer, CachePerformanceFrequency)