Use microseconds instead of milliseconds for built-in profiling

This commit is contained in:
Maxime Coste 2017-06-07 20:06:47 +01:00
parent 1c0bdd8c85
commit b81500c0e4
4 changed files with 14 additions and 13 deletions

View File

@ -115,11 +115,12 @@ void do_profile(size_t count, StringView type)
}
auto after_find = Clock::now();
write_to_debug_buffer(format("{} ({}) -- inserts: {}ms, reads: {}ms, remove: {}ms, find: {}ms ({})", type, count,
std::chrono::duration_cast<std::chrono::milliseconds>(after_insert - start).count(),
std::chrono::duration_cast<std::chrono::milliseconds>(after_read - after_insert).count(),
std::chrono::duration_cast<std::chrono::milliseconds>(after_remove - after_read).count(),
std::chrono::duration_cast<std::chrono::milliseconds>(after_find - after_remove).count(),
using namespace std::chrono;
write_to_debug_buffer(format("{} ({}) -- inserts: {}us, reads: {}us, remove: {}us, find: {}us ({})", type, count,
duration_cast<microseconds>(after_insert - start).count(),
duration_cast<microseconds>(after_read - after_insert).count(),
duration_cast<microseconds>(after_remove - after_read).count(),
duration_cast<microseconds>(after_find - after_remove).count(),
c));
}

View File

@ -128,8 +128,8 @@ void HookManager::run_hook(StringView hook_name,
if (profile)
{
auto end_time = Clock::now();
auto full = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time);
write_to_debug_buffer(format("hook '{}({})' took {} ms", hook_name, param, (size_t)full.count()));
auto full = std::chrono::duration_cast<std::chrono::microseconds>(end_time - start_time);
write_to_debug_buffer(format("hook '{}({})' took {} us", hook_name, param, (size_t)full.count()));
}
}

View File

@ -280,10 +280,10 @@ std::pair<String, int> ShellManager::eval(
if (profile)
{
auto end_time = Clock::now();
auto full = duration_cast<milliseconds>(end_time - start_time);
auto spawn = duration_cast<milliseconds>(wait_time - spawn_time);
auto wait = duration_cast<milliseconds>(end_time - wait_time);
write_to_debug_buffer(format("shell execution took {} ms (spawn: {}, wait: {})",
auto full = duration_cast<microseconds>(end_time - start_time);
auto spawn = duration_cast<microseconds>(wait_time - spawn_time);
auto wait = duration_cast<microseconds>(end_time - wait_time);
write_to_debug_buffer(format("shell execution took {} us (spawn: {}, wait: {})",
(size_t)full.count(), (size_t)spawn.count(), (size_t)wait.count()));
}

View File

@ -147,8 +147,8 @@ const DisplayBuffer& Window::update_display_buffer(const Context& context)
if (profile and not (buffer().flags() & Buffer::Flags::Debug))
{
using namespace std::chrono;
auto duration = duration_cast<milliseconds>(Clock::now() - start_time);
write_to_debug_buffer(format("window display update for '{}' took {} ms",
auto duration = duration_cast<microseconds>(Clock::now() - start_time);
write_to_debug_buffer(format("window display update for '{}' took {} us",
buffer().display_name(), (size_t)duration.count()));
}