diff --git a/libc/test/UnitTest/LibcTest.cpp b/libc/test/UnitTest/LibcTest.cpp --- a/libc/test/UnitTest/LibcTest.cpp +++ b/libc/test/UnitTest/LibcTest.cpp @@ -13,6 +13,13 @@ #include "src/__support/UInt128.h" #include "test/UnitTest/TestLogger.h" +#if __STDC_HOSTED__ +#include +#else +static long clock() { return 0; } +#define CLOCKS_PER_SEC 1 +#endif + namespace __llvm_libc { namespace testing { @@ -162,19 +169,30 @@ continue; } tlog << GREEN << "[ RUN ] " << RESET << TestName << '\n'; + const auto start_time = clock(); RunContext Ctx; T->SetUp(); T->setContext(&Ctx); T->Run(); T->TearDown(); auto Result = Ctx.status(); + const auto duration = clock() - start_time; + const auto elapsed_ms = + static_cast(duration * 1000 / CLOCKS_PER_SEC); switch (Result) { case RunContext::Result_Fail: tlog << RED << "[ FAILED ] " << RESET << TestName << '\n'; ++FailCount; break; case RunContext::Result_Pass: +#if __STDC_HOSTED__ + const auto seconds = static_cast(elapsed_ms / 1000); + const auto frac = static_cast(elapsed_ms % 1000); + tlog << GREEN << "[ OK ] " << RESET << TestName << " (took " + << elapsed_ms << " ms)\n"; +#else tlog << GREEN << "[ OK ] " << RESET << TestName << '\n'; +#endif break; } ++TestCount;