]> git.lizzy.rs Git - minetest.git/blobdiff - src/profiler.cpp
Display whole profiler numbers up to 999999 without scientific notation. (#13155)
[minetest.git] / src / profiler.cpp
index d05b7abfe36cafb0f5425d49c552969f7e7dec90..ab05f7382136937019ece2c9291d666238514373 100644 (file)
@@ -137,7 +137,7 @@ int Profiler::print(std::ostream &o, u32 page, u32 pagecount)
 {
        GraphValues values;
        getPage(values, page, pagecount);
-       char num_buf[50];
+       char buffer[50];
 
        for (const auto &i : values) {
                o << "  " << i.first << " ";
@@ -146,16 +146,17 @@ int Profiler::print(std::ostream &o, u32 page, u32 pagecount)
                        continue;
                }
 
-               s32 space = 44 - i.first.size();
-               for (s32 j = 0; j < space; j++) {
-                       if ((j & 1) && j < space - 1)
-                               o << ".";
-                       else
-                               o << " ";
+               {
+                       // Padding
+                       s32 space = std::max(0, 44 - (s32)i.first.size());
+                       memset(buffer, '_', space);
+                       buffer[space] = '\0';
+                       o << buffer;
                }
-               porting::mt_snprintf(num_buf, sizeof(num_buf), "% 4ix % 3g",
-                               getAvgCount(i.first), i.second);
-               o << num_buf << std::endl;
+
+               porting::mt_snprintf(buffer, sizeof(buffer), "% 5ix % 7g",
+                               getAvgCount(i.first), floor(i.second * 1000.0) / 1000.0);
+               o << buffer << std::endl;
        }
        return values.size();
 }