Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2296)

Unified Diff: tests/Test.cpp

Issue 1811613004: Change SkTime::GetMSecs to double; ensure values stored in SkMSec do not overflow. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Rebase. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/Test.h ('k') | tests/skia_test.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/Test.cpp
diff --git a/tests/Test.cpp b/tests/Test.cpp
index f6f2bdab3d751053f82d14811cb0840185af73dc..dcb08e6badc6bf513740657f01e733c46794f559 100644
--- a/tests/Test.cpp
+++ b/tests/Test.cpp
@@ -36,3 +36,17 @@ SkString skiatest::GetTmpDir() {
const char* tmpDir = FLAGS_tmpDir.isEmpty() ? nullptr : FLAGS_tmpDir[0];
return SkString(tmpDir);
}
+
+skiatest::Timer::Timer() : fStartNanos(SkTime::GetNSecs()) {}
+
+double skiatest::Timer::elapsedNs() const {
+ return SkTime::GetNSecs() - fStartNanos;
+}
+
+double skiatest::Timer::elapsedMs() const { return this->elapsedNs() * 1e-6; }
+
+SkMSec skiatest::Timer::elapsedMsInt() const {
+ const double elapsedMs = this->elapsedMs();
+ SkASSERT(SK_MSecMax >= elapsedMs);
+ return static_cast<SkMSec>(elapsedMs);
+}
« no previous file with comments | « tests/Test.h ('k') | tests/skia_test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698