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

Unified Diff: src/core/SkTime.cpp

Issue 1950173002: Now we're on MSVC 2015, try using std::chrono for timing again. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTime.cpp
diff --git a/src/core/SkTime.cpp b/src/core/SkTime.cpp
index ba8fe3e3a31e9301475fbe2efd8e41c0aead5950..e89d5b9b3a850aebfeb157aa20d974b78a396dee 100644
--- a/src/core/SkTime.cpp
+++ b/src/core/SkTime.cpp
@@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
-#include "SkOncePtr.h"
#include "SkString.h"
#include "SkTime.h"
#include "SkTypes.h"
+#include <chrono>
void SkTime::DateTime::toISO8601(SkString* dst) const {
if (dst) {
@@ -65,37 +65,8 @@ void SkTime::GetDateTime(DateTime* dt) {
}
#endif // SK_BUILD_FOR_WIN32
-#if defined(_MSC_VER)
- // TODO: try std::chrono again with MSVC 2015?
- #include <intrin.h>
- SK_DECLARE_STATIC_ONCE_PTR(double, ns_per_tick);
- double SkTime::GetNSecs() {
- uint64_t ticks = __rdtsc();
- return ticks * *ns_per_tick.get([]{
- LARGE_INTEGER khz; // The docs say this returns Hz, but it returns KHz.
- QueryPerformanceFrequency(&khz);
- return new double(1e6 / khz.QuadPart);
- });
- }
-#elif defined(__MACH__)
- // TODO: fold into std::chrono when available?
- #include <mach/mach_time.h>
- SK_DECLARE_STATIC_ONCE_PTR(double, ns_per_tick);
- double SkTime::GetNSecs() {
- uint64_t ticks = mach_absolute_time();
- return ticks * *ns_per_tick.get([]{
- mach_timebase_info_data_t timebase;
- (void)mach_timebase_info(&timebase);
- return new double(timebase.numer * 1.0 / timebase.denom);
- });
- }
-#else
- // This std::chrono code looks great on Linux and Android,
- // but MSVC 2013 returned mostly garbage (0ns times, etc).
- #include <chrono>
- double SkTime::GetNSecs() {
- auto now = std::chrono::high_resolution_clock::now();
- std::chrono::duration<double, std::nano> ns = now.time_since_epoch();
- return ns.count();
- }
-#endif
+double SkTime::GetNSecs() {
+ auto now = std::chrono::high_resolution_clock::now();
+ std::chrono::duration<double, std::nano> ns = now.time_since_epoch();
+ return ns.count();
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698