From 620c8b9e335ce62fb5a764936219a31586c1ed7d Mon Sep 17 00:00:00 2001 From: Brett Date: Thu, 5 Oct 2023 01:18:47 -0400 Subject: [PATCH] auto_interval, formatting see details for information auto_interval now accepts an interval_t* which must be created manually. allows for clean RAII format now switches to seconds after 1000ms instead of after 100ms. This feels more natural --- include/blt/profiling/profiler_v2.h | 6 ++++++ src/blt/profiling/profiler_v2.cpp | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/blt/profiling/profiler_v2.h b/include/blt/profiling/profiler_v2.h index 4efa824..c9db06a 100644 --- a/include/blt/profiling/profiler_v2.h +++ b/include/blt/profiling/profiler_v2.h @@ -80,6 +80,7 @@ namespace blt }; interval_t* createInterval(profile_t& profiler, std::string interval_name); + void startInterval(interval_t* interval); void endInterval(interval_t* interval); @@ -113,6 +114,11 @@ namespace blt blt::startInterval(iv); } + explicit auto_interval(interval_t* iv): iv(iv) + { + blt::startInterval(iv); + } + auto_interval(const auto_interval& i) = delete; auto_interval& operator=(const auto_interval& i) = delete; diff --git a/src/blt/profiling/profiler_v2.cpp b/src/blt/profiling/profiler_v2.cpp index 1e42be4..d3a5e68 100644 --- a/src/blt/profiling/profiler_v2.cpp +++ b/src/blt/profiling/profiler_v2.cpp @@ -127,14 +127,14 @@ namespace blt // we want to use the largest unit possible to keep the numbers small // we might run into a case where something took 1000ns but other thing took 100s // which would be hard to deal with either way. So TODO - if (wall > 1e5 && wall <= 1e8 && container.wall == unit::NS) + if (wall > 1e6 && wall < 1e9 && container.wall == unit::NS) container.wall = unit::MS; - else if (wall > 1e8) + else if (wall > 1e9) container.wall = unit::S; - if (thread > 1e5 && thread <= 1e8 && container.thread == unit::NS) + if (thread > 1e6 && thread < 1e9 && container.thread == unit::NS) container.thread = unit::MS; - else if (thread > 1e8) + else if (thread > 1e9) container.thread = unit::S; return container; }