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
v1
Brett 2023-10-05 01:18:47 -04:00
parent fd3eb73008
commit 620c8b9e33
2 changed files with 10 additions and 4 deletions

View File

@ -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;

View File

@ -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;
}