fix chrono test
Some checks failed
android / build (push) Successful in 5m0s
linux-arm-gcc / linux-gcc-arm (Release) (push) Failing after 5m3s
linux-arm-gcc / linux-gcc-arm (Debug) (push) Failing after 5m6s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Debug) (push) Failing after 6m20s
linux-mips-gcc / linux-gcc-mipsel (Debug) (push) Failing after 7m11s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Release) (push) Failing after 7m50s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Failing after 4m12s
linux-mips-gcc / linux-gcc-mipsel (Release) (push) Failing after 6m20s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Failing after 6m7s
linux-riscv64-gcc / linux-gcc-riscv64 (Debug) (push) Failing after 6m10s
linux-arm-gcc / linux-gcc-armhf (Release) (push) Failing after 12m33s
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 5m16s
linux-x64-gcc / linux-gcc (Release) (push) Failing after 4m33s
linux-arm-gcc / linux-gcc-armhf (Debug) (push) Failing after 14m37s
linux-riscv64-gcc / linux-gcc-riscv64 (Release) (push) Failing after 8m27s
linux-x86-gcc / linux-gcc (Debug) (push) Failing after 4m54s
linux-x86-gcc / linux-gcc (Release) (push) Failing after 5m9s

This commit is contained in:
tqcq 2024-06-12 11:30:39 +08:00
parent 7c7f73b508
commit 8d1b951a25

View File

@ -6,10 +6,11 @@ namespace tile {
static constexpr auto one = detail::chrono::CoarseClockInitializer::kAccuracy; static constexpr auto one = detail::chrono::CoarseClockInitializer::kAccuracy;
long AvageTime(std::function<long()> f, std::size_t n = 1000) { long AvageTime(std::function<long()> f, std::size_t n = 100) {
long double total = 0; long double total = 0;
for (std::size_t i = 0; i != n; ++i) { for (std::size_t i = 0; i != n; ++i) {
total += 1.0f / n * f(); total += 1.0f / n * f();
std::this_thread::sleep_for(std::chrono::milliseconds(1));
} }
return static_cast<long>(total); return static_cast<long>(total);
} }