From 1154a445af9c04d15b8b2fd0705ea2e5086fd5e6 Mon Sep 17 00:00:00 2001 From: Zach Cobell Date: Sat, 28 Mar 2020 18:00:47 -0600 Subject: [PATCH] Adding additional output data to table --- CMakeLists.txt | 7 +- bench/bench.pro | 2 +- bench/main.cpp | 28 +++- libsmartstack/function.cpp | 10 +- libsmartstack/function.h | 1 + libsmartstack/stack.cpp | 188 ++++++++++++++++++++------- libsmartstack/stack.h | 27 ++-- libsmartstack/timer.cpp | 40 +++++- libsmartstack/timer.h | 10 +- tests/cxx_testSmartStack.cpp | 2 +- tests/ftn_testSmartStack.F90 | 2 + tests/ftn_testSmartStackParallel.F90 | 2 + 12 files changed, 239 insertions(+), 80 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe47fc4..b25576d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,7 +107,6 @@ set(SMARTSTACK_VERSION_PATCH 0) set(SMARTSTACK_VERSION_STRING ${SMARTSTACK_VERSION_MAJOR}.${SMARTSTACK_VERSION_MINOR}.${SMARTSTACK_VERSION_PATCH}) ########################################################################### -OPTION( SMARTSTACK_AGGREGATE "Includes functions deeper in the stack in total time" OFF ) OPTION( SMARTSTACK_BUILDSHARED "Build shared object version of SmartStack" OFF ) IF( SMARTSTACK_BUILDSHARED ) SET( SMARTSTACK_LIBTYPE SHARED ) @@ -143,7 +142,7 @@ ENDIF(SMARTSTACK_BUILD_BENCHMARK) # ABSEIL SWISS TABLES ########################################################################### IF(NOT CYGWIN) - OPTION(SMARTSTACK_USE_ABSEIL_FLAT_MAP "Use the Abseil Swiss Tables to increase speed" ON) + OPTION(SMARTSTACK_USE_ABSEIL_FLAT_MAP "Use the Abseil Swiss Tables to increase speed" OFF) IF(SMARTSTACK_USE_ABSEIL_FLAT_MAP) if(MSVC) # /wd4005 macro-redefinition @@ -179,10 +178,6 @@ SET( SMARTSTACK_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/libsmartstack/timer.cpp ADD_LIBRARY( smartstack ${SMARTSTACK_LIBTYPE} ${SMARTSTACK_SOURCES} ) -IF( SMARTSTACK_AGGREGATE ) - TARGET_COMPILE_DEFINITIONS( smartstack PRIVATE "SMARTSTACK_AGGREGATE" ) -ENDIF( SMARTSTACK_AGGREGATE ) - SET_TARGET_PROPERTIES( smartstack PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles/smartstack ) SET(HEADER_LIST ${CMAKE_SOURCE_DIR}/libsmartstack/smartstack.h ) diff --git a/bench/bench.pro b/bench/bench.pro index 9d49f73..c60d92e 100644 --- a/bench/bench.pro +++ b/bench/bench.pro @@ -21,7 +21,7 @@ QT -= gui CONFIG += c++11 console benchmark CONFIG -= app_bundle -GOOGLE_BENCH_HOME = /opt/google/benchmark +GOOGLE_BENCH_HOME = /opt/google-benchmark INCLUDEPATH += $$GOOGLE_BENCH_HOME/include LIBS += -L$$GOOGLE_BENCH_HOME/lib -lbenchmark -pthread diff --git a/bench/main.cpp b/bench/main.cpp index 277ebb5..bf772e2 100644 --- a/bench/main.cpp +++ b/bench/main.cpp @@ -26,10 +26,12 @@ #include "smartstack.h" const size_t c_functionSize = 500; +std::chrono::high_resolution_clock::time_point t_init; std::vector functionList(c_functionSize); std::vector intList(c_functionSize); void initializer() { + t_init = std::chrono::high_resolution_clock::now(); SmartStack::Stack::startSession("Benchmark"); SmartStack::Stack::startFunction("myfunction"); SmartStack::Stack::endFunction(); @@ -118,6 +120,28 @@ static void bench_lookupNewFunction(benchmark::State& state) { state.SetItemsProcessed(state.iterations()); } +static void bench_startTimer(benchmark::State& state) { + while (state.KeepRunning()) { + benchmark::DoNotOptimize(std::chrono::high_resolution_clock::now()); + } +} + +static void bench_endTimerAndCount(benchmark::State& state) { + while (state.KeepRunning()) { + std::chrono::high_resolution_clock::time_point b = + std::chrono::high_resolution_clock::now(); + benchmark::DoNotOptimize( + std::chrono::duration_cast(b - t_init) + .count()); + } +} + +static void bench_hashString(benchmark::State& state) { + while (state.KeepRunning()) { + benchmark::DoNotOptimize(std::hash()("function_name")); + } +} + BENCHMARK(bench_lookupRandomExistingFunction); BENCHMARK(bench_lookupSameExistingFunction); BENCHMARK(bench_lookupNewFunction); @@ -127,7 +151,9 @@ BENCHMARK(bench_compareInts); BENCHMARK(bench_getFunctionPointer); BENCHMARK(bench_getPointerAndStart); BENCHMARK(bench_createFunctionString); - +BENCHMARK(bench_startTimer); +BENCHMARK(bench_endTimerAndCount); +BENCHMARK(bench_hashString); int main(int argc, char** argv) { initializer(); diff --git a/libsmartstack/function.cpp b/libsmartstack/function.cpp index ee83dde..4eaf02d 100644 --- a/libsmartstack/function.cpp +++ b/libsmartstack/function.cpp @@ -25,17 +25,21 @@ void Function::startFunction() { this->m_ncall++; } -void Function::pauseFunction() { this->m_timer.stopClock(); } +void Function::pauseFunction() { this->m_timer.pause(); } -void Function::restartFunction() { this->m_timer.startClock(); } +void Function::restartFunction() { this->m_timer.restart(); } long long Function::meanDuration() { return this->m_timer.elapsed() / this->m_ncall; } +long long Function::meanGlobalDuration() { + return this->m_timer.globalElapsed() / this->m_ncall; +} + void Function::endFunction() { this->m_timer.stopClock(); } -std::string Function::name() const { return m_name; } +std::string Function::name() const { return this->m_name; } long long Function::numCalls() const { return this->m_ncall; } diff --git a/libsmartstack/function.h b/libsmartstack/function.h index 0dbd94e..d58364d 100644 --- a/libsmartstack/function.h +++ b/libsmartstack/function.h @@ -35,6 +35,7 @@ class Function { void SMARTSTACK_EXPORT restartFunction(); long long SMARTSTACK_EXPORT meanDuration(); + long long SMARTSTACK_EXPORT meanGlobalDuration(); Timer SMARTSTACK_EXPORT *timer(); diff --git a/libsmartstack/stack.cpp b/libsmartstack/stack.cpp index f351ddc..24893e2 100644 --- a/libsmartstack/stack.cpp +++ b/libsmartstack/stack.cpp @@ -56,6 +56,26 @@ bool sortFunctionMeanTimeAscending(const std::unique_ptr &a, return a.get()->meanDuration() < b.get()->meanDuration(); } +bool sortFunctionMeanTotalTimeAscending(const std::unique_ptr &a, + const std::unique_ptr &b) { + return a.get()->meanGlobalDuration() < b.get()->meanGlobalDuration(); +} + +bool sortFunctionMeanTotalTimeDecending(const std::unique_ptr &a, + const std::unique_ptr &b) { + return a.get()->meanGlobalDuration() > b.get()->meanGlobalDuration(); +} + +bool sortFunctionTotalTimeAscending(const std::unique_ptr &a, + const std::unique_ptr &b) { + return a.get()->timer()->globalElapsed() < b.get()->timer()->globalElapsed(); +} + +bool sortFunctionTotalTimeDecending(const std::unique_ptr &a, + const std::unique_ptr &b) { + return a.get()->timer()->globalElapsed() > b.get()->timer()->globalElapsed(); +} + Stack::Stack() : m_procid(-1), m_logfile(std::string()), @@ -185,11 +205,9 @@ Function *Stack::createFunction(const std::string &name) { } void Stack::m_startFunction(const std::string &functionName) { -#ifndef SMARTSTACK_AGGREGATE if (this->m_functionStack.size() > 0) { this->m_functionStack.back()->pauseFunction(); } -#endif Function *f = this->getFunctionPointer(functionName); f->startFunction(); this->m_functionStack.push_back(f); @@ -200,15 +218,13 @@ void Stack::m_endFunction() { Function *f = this->m_functionStack.back(); f->endFunction(); this->m_functionStack.pop_back(); -#ifndef SMARTSTACK_AGGREGATE if (this->m_functionStack.size() > 0) { this->m_functionStack.back()->restartFunction(); } -#endif return; } -void Stack::m_printCurrentStack(const std::string &message) { +void Stack::m_printCurrentStack(const std::string &message) const { if (this->m_logToFile) { std::ofstream f; f.open(this->m_logfile, std::ios::out | std::ios::app); @@ -222,7 +238,7 @@ void Stack::m_printCurrentStack(const std::string &message) { } } -void Stack::m_printCurrentFunction(const std::string &message) { +void Stack::m_printCurrentFunction(const std::string &message) const { if (this->m_logToFile) { std::ofstream f; f.open(this->m_logfile, std::ios::out | std::ios::app); @@ -236,7 +252,7 @@ void Stack::m_printCurrentFunction(const std::string &message) { } } -std::string Stack::m_getCurrentStack(const std::string &message) { +std::string Stack::m_getCurrentStack(const std::string &message) const { bool first = true; std::string s; if (this->m_procid == -1) { @@ -258,14 +274,19 @@ std::string Stack::m_getCurrentStack(const std::string &message) { return s; } -std::string Stack::m_getCurrentFunction(const std::string &message) { +std::string Stack::m_getCurrentFunction(const std::string &message) const { + std::string s; if (this->m_procid == -1) { - return "[" + this->m_sessionName + - "]: " + this->m_functionStack.back()->name(); + s = "[" + this->m_sessionName + + "]: " + this->m_functionStack.back()->name(); } else { - return "[" + this->m_sessionName + " " + this->m_procString + - "]: " + this->m_functionStack.back()->name(); + s = "[" + this->m_sessionName + " " + this->m_procString + + "]: " + this->m_functionStack.back()->name(); } + if (message != std::string()) { + s += ": " + message; + } + return s; } void Stack::sortFunctions(const SortType &st, const SortOrder &so) { @@ -287,6 +308,18 @@ void Stack::sortFunctions(const SortType &st, const SortOrder &so) { } else if (st == MeanTime && so == Decending) { std::sort(this->m_functions.begin(), this->m_functions.end(), sortFunctionMeanTimeDecending); + } else if (st == MeanTotalTime && so == Decending) { + std::sort(this->m_functions.begin(), this->m_functions.end(), + sortFunctionMeanTotalTimeDecending); + } else if (st == MeanTotalTime && so == Ascending) { + std::sort(this->m_functions.begin(), this->m_functions.end(), + sortFunctionMeanTotalTimeAscending); + } else if (st == TotalTime && so == Decending) { + std::sort(this->m_functions.begin(), this->m_functions.end(), + sortFunctionTotalTimeDecending); + } else if (st == TotalTime && so == Ascending) { + std::sort(this->m_functions.begin(), this->m_functions.end(), + sortFunctionTotalTimeAscending); } else { std::sort(this->m_functions.begin(), this->m_functions.end(), sortFunctionTimeDecending); @@ -295,7 +328,8 @@ void Stack::sortFunctions(const SortType &st, const SortOrder &so) { } void Stack::getSortCodes(std::string &calls, std::string &duration, - std::string &meanDuration, const SortType &st, + std::string &meanDuration, std::string &totalDuration, + std::string &meanTotalDuration, const SortType &st, const Stack::SortOrder &so) { std::string upArrow = "[^]"; std::string downArrow = "[v]"; @@ -304,15 +338,33 @@ void Stack::getSortCodes(std::string &calls, std::string &duration, if (st == SortType::Time) { calls = blank; meanDuration = blank; + totalDuration = blank; + meanTotalDuration = blank; duration = so == Ascending ? upArrow : downArrow; } else if (st == SortType::Calls) { calls = so == Ascending ? upArrow : downArrow; meanDuration = blank; duration = blank; + totalDuration = blank; + meanTotalDuration = blank; } else if (st == SortType::MeanTime) { calls = blank; + totalDuration = blank; + meanTotalDuration = blank; meanDuration = so == Ascending ? upArrow : downArrow; duration = blank; + } else if (st == SortType::TotalTime) { + calls = blank; + meanDuration = blank; + meanTotalDuration = blank; + totalDuration = so == Ascending ? upArrow : downArrow; + duration = blank; + } else if (st == SortType::MeanTotalTime) { + calls = blank; + meanDuration = blank; + totalDuration = blank; + meanTotalDuration = so == Ascending ? upArrow : downArrow; + duration = blank; } return; } @@ -320,26 +372,33 @@ void Stack::getSortCodes(std::string &calls, std::string &duration, std::vector Stack::generateTimingReport(const SortType &st, const SortOrder &so) { this->sortFunctions(st, so); - std::string callCode, durationCode, meanDurationCode; - this->getSortCodes(callCode, durationCode, meanDurationCode, st, so); + std::string callCode, durationCode, meanDurationCode, totalDurationCode, + meanTotalDurationCode; + this->getSortCodes(callCode, durationCode, meanDurationCode, + totalDurationCode, meanTotalDurationCode, st, so); std::string unit = this->m_unitsString(this->m_reportUnits); std::vector table; + + size_t padsize = (this->maxNumFunctionChars(13) - 13) / 2; + std::string pad = std::string(padsize + 1, ' '); + std::string dashfn = std::string(2 * padsize + 15, '-'); + std::string fn = pad + "Function Name" + pad; + std::string headerbar = + "|----------|" + dashfn + + "|-------------|----------------------------|----------------------------" + "---|----------------------------------|---------------------------------" + "-----|"; + table.push_back("Function report for: " + this->m_sessionName); - table.push_back( - "|----------|----------------------------------------------------|-----" - "--" - "------|-------------" - "---------|-------------------------|"); - table.push_back( - "| Rank | Function Name | " + - callCode + " Calls | " + durationCode + " Duration " + unit + " | " + - meanDurationCode + " Mean Duration " + unit + " |"); - table.push_back( - "|----------|----------------------------------------------------|-----" - "--" - "------|-------------" - "---------|-------------------------|"); + table.push_back(headerbar); + table.push_back("| Rank |" + fn + "| " + callCode + " Calls | " + + durationCode + " Local Duration " + unit + " | " + + meanDurationCode + " Mean Local Duration " + unit + " | " + + totalDurationCode + " Local + Child Duration " + unit + + " | " + meanTotalDurationCode + + " Mean Local + Child Duration " + unit + " |"); + table.push_back(headerbar); size_t i = 0; for (auto &f : this->m_functions) { @@ -348,11 +407,7 @@ std::vector Stack::generateTimingReport(const SortType &st, this->m_getFunctionReportLine(i, f.get(), this->m_reportUnits); table.push_back(line); } - table.push_back( - "|----------|----------------------------------------------------|-----" - "--" - "------|-------------" - "---------|-------------------------|"); + table.push_back(headerbar); return table; } @@ -360,7 +415,7 @@ void Stack::m_setReportUnits(const Stack::TimeUnits &units) { this->m_reportUnits = units; } -std::string Stack::m_unitsString(const Stack::TimeUnits &units) { +std::string Stack::m_unitsString(const Stack::TimeUnits &units) const { switch (units) { case Microseconds: return "(us)"; @@ -375,7 +430,7 @@ std::string Stack::m_unitsString(const Stack::TimeUnits &units) { } } -void Stack::m_printTimingReport(const std::vector &report) { +void Stack::m_printTimingReport(const std::vector &report) const { for (auto &s : report) { std::cout << s << std::endl; } @@ -383,7 +438,7 @@ void Stack::m_printTimingReport(const std::vector &report) { } void Stack::m_saveTimimgReport(const std::vector &report, - const std::string &filename) { + const std::string &filename) const { std::ofstream output(filename); for (auto &s : report) { output << s << std::endl; @@ -392,8 +447,8 @@ void Stack::m_saveTimimgReport(const std::vector &report, return; } -std::string Stack::m_getFunctionReportLine(size_t i, Function *f, - const Stack::TimeUnits &units) { +std::string Stack::m_getFunctionReportLine( + size_t i, Function *f, const Stack::TimeUnits &units) const { char line[400]; if (units == Seconds || units == Hours || units == Minutes || units == Milliseconds) { @@ -416,18 +471,51 @@ std::string Stack::m_getFunctionReportLine(size_t i, Function *f, break; } - long long t = f->timer()->elapsed() / multiplier; - double ts = static_cast(t) + - static_cast(f->timer()->elapsed() - t) / multiplier; - long long mt = f->meanDuration() / multiplier; - double mts = static_cast(mt) + - static_cast(f->meanDuration() - mt) / multiplier; - snprintf(line, 400, "| %8zu | %50s | %11lld | %9.9e | %9.9e |", - i, f->name().c_str(), f->numCalls(), ts, mts); + double ts = this->convertTimeUnitsDouble(f->timer()->elapsed(), multiplier); + double mts = this->convertTimeUnitsDouble(f->meanDuration(), multiplier); + double ats = + this->convertTimeUnitsDouble(f->timer()->globalElapsed(), multiplier); + double amts = + this->convertTimeUnitsDouble(f->meanGlobalDuration(), multiplier); + + size_t fnnamemx = this->maxNumFunctionChars(13); + std::string formatLine = + std::string() + "| %8zu | %" + formatStringChar(fnnamemx) + + "s | %11lld | %9.9e | %9.9e | " + " %9.9e | %9.9e |"; + + snprintf(line, 400, formatLine.c_str(), i, f->name().c_str(), f->numCalls(), + ts, mts, ats, amts); } else { - snprintf(line, 400, "| %8zu | %50s | %11lld | %18lld | %18lld |", i, - f->name().c_str(), f->numCalls(), f->timer()->elapsed(), - f->meanDuration()); + size_t fnnamemx = this->maxNumFunctionChars(13); + std::string formatLine = std::string() + "| %8zu | %" + + formatStringChar(fnnamemx) + + "s | %11lld | %18lld | %18lld " + "| %18lld | " + " %18lld |"; + snprintf(line, 400, formatLine.c_str(), i, f->name().c_str(), f->numCalls(), + f->timer()->elapsed(), f->meanDuration(), + f->timer()->globalElapsed(), f->meanGlobalDuration()); } return std::string(line); } + +double Stack::convertTimeUnitsDouble(const long long time, + const double multiplier) const { + long long t = time / multiplier; + return static_cast(t) + static_cast(time - t) / multiplier; +} + +size_t Stack::maxNumFunctionChars(size_t lowerLimit) const { + size_t mx = lowerLimit; + for (auto &f : this->m_functions) { + mx = std::max(mx, f->name().size()); + } + return mx; +} + +std::string Stack::formatStringChar(size_t n) const { + char line[20]; + snprintf(line, 20, "%zu", n); + return std::string(line); +} diff --git a/libsmartstack/stack.h b/libsmartstack/stack.h index fff1457..af8c7d8 100644 --- a/libsmartstack/stack.h +++ b/libsmartstack/stack.h @@ -38,7 +38,7 @@ namespace SmartStack { class Stack { public: enum SortOrder { Ascending, Decending }; - enum SortType { Time, MeanTime, Calls }; + enum SortType { Time, MeanTime, TotalTime, MeanTotalTime, Calls }; enum TimeUnits { Microseconds, Milliseconds, Seconds, Minutes, Hours }; static void SMARTSTACK_EXPORT @@ -95,23 +95,30 @@ class Stack { void m_endSession(); void m_endFunction(); void m_startFunction(const std::string &functionName); - void m_printCurrentFunction(const std::string &message = std::string()); - void m_printCurrentStack(const std::string &message = std::string()); - void m_printTimingReport(const std::vector &report); + void m_printCurrentFunction(const std::string &message = std::string()) const; + void m_printCurrentStack(const std::string &message = std::string()) const; + void m_printTimingReport(const std::vector &report) const; void m_saveTimimgReport(const std::vector &report, - const std::string &filename); + const std::string &filename) const; std::string m_getFunctionReportLine(size_t i, Function *f, - const TimeUnits &units); - std::string m_getCurrentStack(const std::string &message = std::string()); - std::string m_getCurrentFunction(const std::string &message = std::string()); + const TimeUnits &units) const; + std::string m_getCurrentStack( + const std::string &message = std::string()) const; + std::string m_getCurrentFunction( + const std::string &message = std::string()) const; void sortFunctions(const SortType &st, const SortOrder &so); void getSortCodes(std::string &calls, std::string &duration, - std::string &meanDuration, const Stack::SortType &st, + std::string &meanDuration, std::string &totalDuration, + std::string &meanTotalDuration, const SortType &st, const Stack::SortOrder &so); std::vector generateTimingReport(const SortType &st, const SortOrder &so); void m_setReportUnits(const Stack::TimeUnits &units); - std::string m_unitsString(const Stack::TimeUnits &units); + std::string m_unitsString(const Stack::TimeUnits &units) const; + double convertTimeUnitsDouble(const long long time, + const double multiplier) const; + size_t maxNumFunctionChars(size_t lowerLimit = 0) const; + std::string formatStringChar(size_t n) const; void writeHeader(); void writeFooter(); diff --git a/libsmartstack/timer.cpp b/libsmartstack/timer.cpp index d1859b4..70de59f 100644 --- a/libsmartstack/timer.cpp +++ b/libsmartstack/timer.cpp @@ -18,34 +18,62 @@ //------------------------------------------------------------------------// #include "timer.h" -Timer::Timer() : m_totalElapsed(0), m_lastElapsed(0), m_running(false) {} +Timer::Timer() + : m_totalElapsed(0), + m_lastElapsed(0), + m_totalGlobalElapsed(0), + m_running(false) {} void Timer::startClock() { this->m_running = true; - this->m_start = std::chrono::high_resolution_clock::now(); + this->m_startLocal = std::chrono::high_resolution_clock::now(); + this->m_startGlobal = this->m_startLocal; } void Timer::stopClock() { if (this->m_running) { - this->m_end = std::chrono::high_resolution_clock::now(); + this->m_endLocal = std::chrono::high_resolution_clock::now(); + this->m_endGlobal = this->m_endLocal; this->m_lastElapsed = std::chrono::duration_cast( - this->m_end - this->m_start) + this->m_endLocal - this->m_startLocal) .count(); this->m_totalElapsed += this->m_lastElapsed; + this->m_totalGlobalElapsed += + std::chrono::duration_cast( + this->m_endGlobal - this->m_startGlobal) + .count(); this->m_running = false; } } +void Timer::pause() { + if (this->m_running) { + this->m_endLocal = std::chrono::high_resolution_clock::now(); + this->m_lastElapsed = std::chrono::duration_cast( + this->m_endLocal - this->m_startLocal) + .count(); + this->m_totalElapsed += this->m_lastElapsed; + } +} + +void Timer::restart() { + this->m_startLocal = std::chrono::high_resolution_clock::now(); +} + long long Timer::elapsed() const { return this->m_totalElapsed; } +long long Timer::globalElapsed() const { return this->m_totalGlobalElapsed; } + long long Timer::startTime() const { - return std::chrono::time_point_cast(this->m_start) + return std::chrono::time_point_cast( + this->m_startLocal) .time_since_epoch() .count(); } long long Timer::endTime() const { - return std::chrono::time_point_cast(this->m_end) + return std::chrono::time_point_cast( + this->m_endLocal) .time_since_epoch() .count(); } diff --git a/libsmartstack/timer.h b/libsmartstack/timer.h index a312680..28ee4dc 100644 --- a/libsmartstack/timer.h +++ b/libsmartstack/timer.h @@ -28,7 +28,10 @@ class Timer { SMARTSTACK_EXPORT Timer(); void SMARTSTACK_EXPORT startClock(); void SMARTSTACK_EXPORT stopClock(); + void SMARTSTACK_EXPORT pause(); + void SMARTSTACK_EXPORT restart(); long long SMARTSTACK_EXPORT elapsed() const; + long long SMARTSTACK_EXPORT globalElapsed() const; long long SMARTSTACK_EXPORT startTime() const; long long SMARTSTACK_EXPORT endTime() const; long long SMARTSTACK_EXPORT lastElapsed() const; @@ -37,9 +40,12 @@ class Timer { private: long long m_totalElapsed; long long m_lastElapsed; + long long m_totalGlobalElapsed; bool m_running; - std::chrono::high_resolution_clock::time_point m_start; - std::chrono::high_resolution_clock::time_point m_end; + std::chrono::high_resolution_clock::time_point m_startLocal; + std::chrono::high_resolution_clock::time_point m_endLocal; + std::chrono::high_resolution_clock::time_point m_startGlobal; + std::chrono::high_resolution_clock::time_point m_endGlobal; }; #endif // TIMER_H diff --git a/tests/cxx_testSmartStack.cpp b/tests/cxx_testSmartStack.cpp index 745dfb3..dc3d4a4 100644 --- a/tests/cxx_testSmartStack.cpp +++ b/tests/cxx_testSmartStack.cpp @@ -33,7 +33,7 @@ int main(int argv, char** argc) { } END_SMARTSTACK(); - SmartStack::printTimingReport(); + SmartStack::printTimingReport(SmartStack::Stack::TotalTime,SmartStack::Stack::Ascending); return 0; } diff --git a/tests/ftn_testSmartStack.F90 b/tests/ftn_testSmartStack.F90 index 62ed8f8..aaf88ed 100644 --- a/tests/ftn_testSmartStack.F90 +++ b/tests/ftn_testSmartStack.F90 @@ -50,6 +50,8 @@ PROGRAM smartstack_test CALL SMART1() CALL SMART2() + CALL SmartStack_EndSession() + CALL SmartStack_printTimingReport() CALL SmartStack_setReportUnits(SMARTSTACK_MILLISECONDS) diff --git a/tests/ftn_testSmartStackParallel.F90 b/tests/ftn_testSmartStackParallel.F90 index e8afc99..a81ae6e 100644 --- a/tests/ftn_testSmartStackParallel.F90 +++ b/tests/ftn_testSmartStackParallel.F90 @@ -50,6 +50,8 @@ PROGRAM smartstack_test CALL SMART1() CALL SMART2() + CALL SmartStack_endSession() + CALL SmartStack_printTimingReport() CALL SmartStack_setReportUnits(SMARTSTACK_MILLISECONDS)