aboutsummaryrefslogtreecommitdiff
path: root/lib/arm_profiler/src/arm_profiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arm_profiler/src/arm_profiler.cpp')
-rw-r--r--lib/arm_profiler/src/arm_profiler.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/arm_profiler/src/arm_profiler.cpp b/lib/arm_profiler/src/arm_profiler.cpp
index c58037f..95bc3e4 100644
--- a/lib/arm_profiler/src/arm_profiler.cpp
+++ b/lib/arm_profiler/src/arm_profiler.cpp
@@ -28,7 +28,7 @@
namespace tflite {
-ArmProfiler::ArmProfiler(size_t max_events) : max_events_(max_events) {
+ArmProfiler::ArmProfiler(size_t max_events) : max_events_(max_events), num_events_(0) {
tags_ = std::make_unique<const char *[]>(max_events_);
start_ticks_ = std::make_unique<int32_t[]>(max_events_);
end_ticks_ = std::make_unique<int32_t[]>(max_events_);
@@ -39,9 +39,11 @@ uint32_t ArmProfiler::BeginEvent(const char *tag) {
tflite::GetMicroErrorReporter()->Report("Profiling event overflow, max: %u events", max_events_);
num_events_ = 0;
}
+
tags_[num_events_] = tag;
start_ticks_[num_events_] = GetCurrentTimeTicks();
end_ticks_[num_events_] = start_ticks_[num_events_] - 1;
+
return num_events_++;
}
@@ -54,9 +56,11 @@ void ArmProfiler::EndEvent(uint32_t event_handle) {
int32_t ArmProfiler::GetTotalTicks() const {
int32_t ticks = 0;
- for (int i = 0; i < num_events_; ++i) {
+
+ for (size_t i = 0; i < num_events_; ++i) {
ticks += end_ticks_[i] - start_ticks_[i];
}
+
return ticks;
}