aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/timer/Timer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/timer/Timer.cpp')
-rw-r--r--tools/timer/Timer.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/timer/Timer.cpp b/tools/timer/Timer.cpp
index 28841cdc84..01ffb96674 100644
--- a/tools/timer/Timer.cpp
+++ b/tools/timer/Timer.cpp
@@ -17,3 +17,15 @@ SkString HumanizeMs(double ms) {
#endif
return SkStringPrintf("%.3gms", ms);
}
+
+int HumanizeMs(char* s, int len, double ms) {
+ if (ms > 60e+3) return snprintf(s, len, "%.3gm", ms / 60e+3);
+ if (ms > 1e+3) return snprintf(s, len, "%.3gs", ms / 1e+3);
+ if (ms < 1e-3) return snprintf(s, len, "%.3gns", ms*1e+6);
+#ifdef SK_BUILD_FOR_WIN
+ if (ms < 1) return snprintf(s, len, "%.3gus", ms*1e+3);
+#else
+ if (ms < 1) return snprintf(s, len, "%.3gµs", ms*1e+3);
+#endif
+ return snprintf(s, len, "%.3gms", ms);
+}