From b81500c0e4c5dac5c976fc5553658d9f009ddf00 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 7 Jun 2017 20:06:47 +0100 Subject: [PATCH] Use microseconds instead of milliseconds for built-in profiling --- src/hash_map.cc | 11 ++++++----- src/hook_manager.cc | 4 ++-- src/shell_manager.cc | 8 ++++---- src/window.cc | 4 ++-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/hash_map.cc b/src/hash_map.cc index 5799f87b..95b75f18 100644 --- a/src/hash_map.cc +++ b/src/hash_map.cc @@ -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(after_insert - start).count(), - std::chrono::duration_cast(after_read - after_insert).count(), - std::chrono::duration_cast(after_remove - after_read).count(), - std::chrono::duration_cast(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(after_insert - start).count(), + duration_cast(after_read - after_insert).count(), + duration_cast(after_remove - after_read).count(), + duration_cast(after_find - after_remove).count(), c)); } diff --git a/src/hook_manager.cc b/src/hook_manager.cc index ef7139b3..fc274f8a 100644 --- a/src/hook_manager.cc +++ b/src/hook_manager.cc @@ -128,8 +128,8 @@ void HookManager::run_hook(StringView hook_name, if (profile) { auto end_time = Clock::now(); - auto full = std::chrono::duration_cast(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(end_time - start_time); + write_to_debug_buffer(format("hook '{}({})' took {} us", hook_name, param, (size_t)full.count())); } } diff --git a/src/shell_manager.cc b/src/shell_manager.cc index f34b611d..ba6939d0 100644 --- a/src/shell_manager.cc +++ b/src/shell_manager.cc @@ -280,10 +280,10 @@ std::pair ShellManager::eval( if (profile) { auto end_time = Clock::now(); - auto full = duration_cast(end_time - start_time); - auto spawn = duration_cast(wait_time - spawn_time); - auto wait = duration_cast(end_time - wait_time); - write_to_debug_buffer(format("shell execution took {} ms (spawn: {}, wait: {})", + auto full = duration_cast(end_time - start_time); + auto spawn = duration_cast(wait_time - spawn_time); + auto wait = duration_cast(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())); } diff --git a/src/window.cc b/src/window.cc index 262c6979..1dee2c2a 100644 --- a/src/window.cc +++ b/src/window.cc @@ -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(Clock::now() - start_time); - write_to_debug_buffer(format("window display update for '{}' took {} ms", + auto duration = duration_cast(Clock::now() - start_time); + write_to_debug_buffer(format("window display update for '{}' took {} us", buffer().display_name(), (size_t)duration.count())); }