blob: 28841cdc846f9a93efd02dbb696c36c17b245169 [file] [log] [blame]
mtklein9ac68ee2014-06-20 11:29:20 -07001/*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#include "Timer.h"
Hal Canary8a001442018-09-19 11:31:27 -04008
mtklein748ca3b2015-01-15 10:56:12 -08009SkString HumanizeMs(double ms) {
mtkleind1f7f992015-03-12 10:29:32 -070010 if (ms > 60e+3) return SkStringPrintf("%.3gm", ms/60e+3);
11 if (ms > 1e+3) return SkStringPrintf("%.3gs", ms/1e+3);
12 if (ms < 1e-3) return SkStringPrintf("%.3gns", ms*1e+6);
mtklein748ca3b2015-01-15 10:56:12 -080013#ifdef SK_BUILD_FOR_WIN
mtkleind1f7f992015-03-12 10:29:32 -070014 if (ms < 1) return SkStringPrintf("%.3gus", ms*1e+3);
mtklein748ca3b2015-01-15 10:56:12 -080015#else
mtkleind1f7f992015-03-12 10:29:32 -070016 if (ms < 1) return SkStringPrintf("%.3gµs", ms*1e+3);
mtklein748ca3b2015-01-15 10:56:12 -080017#endif
18 return SkStringPrintf("%.3gms", ms);
19}