aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/timer/Timer.cpp12
-rw-r--r--tools/timer/Timer.h1
2 files changed, 13 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);
+}
diff --git a/tools/timer/Timer.h b/tools/timer/Timer.h
index 446eb254fd..9b0f7b2b98 100644
--- a/tools/timer/Timer.h
+++ b/tools/timer/Timer.h
@@ -22,5 +22,6 @@ public:
};
SkString HumanizeMs(double);
+int HumanizeMs(char*, int len, double);
#endif