From a687dc13f7b60b9affb0d197803903d5b3878cf4 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 24 Nov 2024 10:49:13 +0100 Subject: [PATCH] Add time print mode to test application --- src/test-sample/test.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/test-sample/test.cpp b/src/test-sample/test.cpp index 2e7b9dcc..e8a8460f 100644 --- a/src/test-sample/test.cpp +++ b/src/test-sample/test.cpp @@ -4,10 +4,14 @@ #include #include #include -#include #include +#include +#include + #include +using namespace std::literals; + // Externally visible and potentially modifiable state // to trick compiler optimizations __declspec(dllexport) bool do_the_task = true; @@ -178,6 +182,12 @@ bool test_native_exceptions() } } +void print_time() +{ + const auto epoch_time = std::chrono::system_clock::now().time_since_epoch(); + printf("Time: %lld\n", epoch_time.count()); +} + #define RUN_TEST(func, name) \ { \ printf("Running test '" name "': "); \ @@ -186,8 +196,14 @@ bool test_native_exceptions() puts(res ? "Success" : "Fail"); \ } -int main(int /*argc*/, const char* /*argv*/[]) +int main(int argc, const char* argv[]) { + if(argc == 2 && argv[1] == "-time"sv) + { + print_time(); + return 0; + } + bool valid = true; RUN_TEST(test_io, "I/O")