From 23cbc2548709f3767602ffa2a1f5cfbe7ee7a7ad Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 7 Feb 2024 14:01:00 +0800 Subject: [PATCH] some fix --- src/profiler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/profiler.cpp b/src/profiler.cpp index 34238554..fd5fedff 100644 --- a/src/profiler.cpp +++ b/src/profiler.cpp @@ -8,7 +8,7 @@ static std::string left_pad(std::string s, int width){ return std::string(n, ' ') + s; } -static std::string to_string_1f(double x){ +static std::string to_string_1f(f64 x){ char buf[32]; snprintf(buf, 32, "%.1f", x); return buf; @@ -64,7 +64,7 @@ Str LineProfiler::stats(){ for(auto& [line, record] : file_records){ total_time += record.time; } - ss << "Total time: " << (double)total_time / CLOCKS_PER_SEC << "s\n"; + ss << "Total time: " << (f64)total_time / CLOCKS_PER_SEC << "s\n"; ss << "File: " << filename << "\n"; // ss << "Function: " << "" << "at line " << -1 << "\n"; ss << "Line # Hits Time Per Hit % Time Line Contents\n"; @@ -74,7 +74,7 @@ Str LineProfiler::stats(){ ss << left_pad(std::to_string(record.hits), 10); ss << left_pad(std::to_string(record.time), 13); ss << left_pad(std::to_string(record.time_per_hit()), 9); - ss << left_pad(to_string_1f(record.time * 100.0 / total_time), 9); + ss << left_pad(to_string_1f(record.time * (f64)100 / total_time), 9); ss << " " << record.line_content() << "\n"; } ss << "\n";