summaryrefslogtreecommitdiff
path: root/runtime/libs/benchmark/src/Result.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/libs/benchmark/src/Result.cpp')
-rw-r--r--runtime/libs/benchmark/src/Result.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/runtime/libs/benchmark/src/Result.cpp b/runtime/libs/benchmark/src/Result.cpp
index df573da92..8c1e2d2ea 100644
--- a/runtime/libs/benchmark/src/Result.cpp
+++ b/runtime/libs/benchmark/src/Result.cpp
@@ -57,7 +57,7 @@ double minTimeMs(const benchmark::Phase &phase)
double geomeanTimeMs(const benchmark::Phase &phase)
{
double log_sum = 0.0;
- for (auto t_us : phase.time)
+ for (auto &&t_us : phase.time)
{
log_sum += std::log(t_us / 1e3);
}
@@ -77,9 +77,9 @@ uint32_t averageMemoryKb(const benchmark::Phase &phase, int type)
return average<uint32_t, uint32_t>(phase.memory[type]);
}
-uint32_t peakMemory(const uint32_t memory[benchmark::PhaseEnum::END_OF_PHASE]
- [benchmark::MemoryType::END_OF_MEM_TYPE],
- int type)
+uint32_t peakMemory(
+ const uint32_t memory[benchmark::PhaseEnum::END_OF_PHASE][benchmark::MemoryType::END_OF_MEM_TYPE],
+ int type)
{
using namespace benchmark;
// tricky. handle WARMUP as EXECUTE
@@ -88,7 +88,7 @@ uint32_t peakMemory(const uint32_t memory[benchmark::PhaseEnum::END_OF_PHASE]
}
void printResultTime(
- const double time[benchmark::PhaseEnum::END_OF_PHASE][benchmark::FigureType::END_OF_FIG_TYPE])
+ const double time[benchmark::PhaseEnum::END_OF_PHASE][benchmark::FigureType::END_OF_FIG_TYPE])
{
using namespace benchmark;
@@ -119,8 +119,8 @@ void printResultTime(
std::cout << "===================================" << std::endl;
}
-void printResultMemory(const uint32_t memory[benchmark::PhaseEnum::END_OF_PHASE]
- [benchmark::MemoryType::END_OF_MEM_TYPE])
+void printResultMemory(
+ const uint32_t memory[benchmark::PhaseEnum::END_OF_PHASE][benchmark::MemoryType::END_OF_MEM_TYPE])
{
using namespace benchmark;
@@ -141,6 +141,15 @@ void printResultMemory(const uint32_t memory[benchmark::PhaseEnum::END_OF_PHASE]
}
}
+void printUsedPeakMemory(uint32_t init_memory, uint32_t peak_memory)
+{
+ uint32_t used_peak_memory = peak_memory - init_memory;
+ std::cout << "Used Peak Memory : " << used_peak_memory << " kb" << std::endl;
+ std::cout << "- HWM after run : " << peak_memory << " kb" << std::endl;
+ std::cout << "- HWM before init: " << init_memory << " kb" << std::endl;
+ std::cout << "===================================" << std::endl;
+}
+
} // namespace
namespace benchmark
@@ -148,16 +157,16 @@ namespace benchmark
Result::Result(const Phases &phases)
{
- const auto option = phases.option();
+ const auto &option = phases.option();
{
for (int i = PhaseEnum::MODEL_LOAD; i <= PhaseEnum::PREPARE; ++i)
{
- auto phase = phases.at(gPhaseStrings[i]);
+ const auto &phase = phases.at(gPhaseStrings[i]);
time[i][FigureType::MEAN] = averageTimeMs(phase);
}
int i = PhaseEnum::EXECUTE;
- auto exec_phase = phases.at(gPhaseStrings[i]);
+ const auto &exec_phase = phases.at(gPhaseStrings[i]);
time[i][FigureType::MEAN] = averageTimeMs(exec_phase);
time[i][FigureType::MAX] = maxTimeMs(exec_phase);
time[i][FigureType::MIN] = minTimeMs(exec_phase);
@@ -175,6 +184,8 @@ Result::Result(const Phases &phases)
}
}
}
+ init_memory = phases.mem_before_init();
+ peak_memory = phases.mem_after_run();
}
void printResult(const Result &result)
@@ -185,6 +196,7 @@ void printResult(const Result &result)
return;
printResultMemory(result.memory);
+ printUsedPeakMemory(result.init_memory, result.peak_memory);
}
// TODO There are necessary for a kind of output data file so that it doesn't have to be csv file