summaryrefslogtreecommitdiff
path: root/src/command_manager.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2023-08-12 13:06:53 +1000
committerMaxime Coste <mawww@kakoune.org>2023-08-13 03:57:46 +1000
commite090131b8705124e8ab78de076f4e8f25ba7746e (patch)
treeb97a797e55dfdea7ef55196c259b214e71cc55ee /src/command_manager.cc
parente605ad8582d8e015806ed9b4d7aba8ca1ea13d57 (diff)
Add a ProfileScope helper class to replace most profiling uses
Diffstat (limited to 'src/command_manager.cc')
-rw-r--r--src/command_manager.cc10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/command_manager.cc b/src/command_manager.cc
index e1b44888..68ea6c63 100644
--- a/src/command_manager.cc
+++ b/src/command_manager.cc
@@ -8,6 +8,7 @@
#include "file.hh"
#include "optional.hh"
#include "option_types.hh"
+#include "profile.hh"
#include "ranges.hh"
#include "regex.hh"
#include "register_manager.hh"
@@ -525,12 +526,9 @@ void CommandManager::execute_single_command(CommandParameters params,
if (debug_flags & DebugFlags::Commands)
write_to_debug_buffer(format("command {}", join(params, ' ')));
- auto profile = on_scope_end([&, start = (debug_flags & DebugFlags::Profile) ? Clock::now() : Clock::time_point{}] {
- if (not (debug_flags & DebugFlags::Profile))
- return;
- auto full = std::chrono::duration_cast<std::chrono::microseconds>(Clock::now() - start);
- write_to_debug_buffer(format("command {} took {} us", params[0], full.count()));
- });
+ ProfileScope profile{debug_flags, [&](std::chrono::microseconds duration) {
+ write_to_debug_buffer(format("command {} took {} us", params[0], duration.count()));
+ }};
command_it->value.func({{params.begin()+1, params.end()}, command_it->value.param_desc},
context, shell_context);