1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2011 Google Inc. 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci#include "tools/timer/Timer.h" 8cb93a386Sopenharmony_ci 9cb93a386Sopenharmony_ciSkString HumanizeMs(double ms) { 10cb93a386Sopenharmony_ci if (ms > 60e+3) return SkStringPrintf("%.3gm", ms/60e+3); 11cb93a386Sopenharmony_ci if (ms > 1e+3) return SkStringPrintf("%.3gs", ms/1e+3); 12cb93a386Sopenharmony_ci if (ms < 1e-3) return SkStringPrintf("%.3gns", ms*1e+6); 13cb93a386Sopenharmony_ci#ifdef SK_BUILD_FOR_WIN 14cb93a386Sopenharmony_ci if (ms < 1) return SkStringPrintf("%.3gus", ms*1e+3); 15cb93a386Sopenharmony_ci#else 16cb93a386Sopenharmony_ci if (ms < 1) return SkStringPrintf("%.3gµs", ms*1e+3); 17cb93a386Sopenharmony_ci#endif 18cb93a386Sopenharmony_ci return SkStringPrintf("%.3gms", ms); 19cb93a386Sopenharmony_ci} 20