diff options
| author | Frank LENORMAND <lenormf@gmail.com> | 2018-12-21 15:03:21 +0300 |
|---|---|---|
| committer | Frank LENORMAND <lenormf@gmail.com> | 2018-12-23 09:26:12 +0300 |
| commit | 623c8a76f412abc75dd56258ba71a97772092a23 (patch) | |
| tree | 511729abaf7073bff0b899cf8061c152e2e094c8 /src | |
| parent | 7b847f20dddad39d0b34c12dc3d0f31f463d7485 (diff) | |
src: Run and display the time taken by unit tests to run in debug mode
Knowing how much time the editor took to run unit tests gives users
a notion of how fast it's performing on a given system.
Diffstat (limited to 'src')
| -rw-r--r-- | src/clock.hh | 1 | ||||
| -rw-r--r-- | src/main.cc | 8 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/clock.hh b/src/clock.hh index b4138de0..741c049c 100644 --- a/src/clock.hh +++ b/src/clock.hh @@ -8,6 +8,7 @@ namespace Kakoune using Clock = std::chrono::steady_clock; using TimePoint = Clock::time_point; +using DurationMs = std::chrono::milliseconds; } diff --git a/src/main.cc b/src/main.cc index 608aefac..3ede4f1c 100644 --- a/src/main.cc +++ b/src/main.cc @@ -26,6 +26,7 @@ #include "string.hh" #include "unit_tests.hh" #include "window.hh" +#include "clock.hh" #include <fcntl.h> #include <locale> @@ -651,9 +652,14 @@ int run_server(StringView session, StringView server_init, global_scope.options()["debug"].set(debug_flags); + write_to_debug_buffer("*** This is the debug buffer, where debug info will be written ***"); + + const auto start_time = Clock::now(); UnitTest::run_all_tests(); - write_to_debug_buffer("*** This is the debug buffer, where debug info will be written ***"); + if (debug_flags & DebugFlags::Profile) + write_to_debug_buffer(format("running the unit tests took {} ms", + std::chrono::duration_cast<DurationMs>(Clock::now() - start_time).count())); GlobalScope::instance().options().get_local_option("readonly").set<bool>(flags & ServerFlags::ReadOnly); |
