/src/skia/src/base/SkTime.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2023 Google LLC |
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 | | |
8 | | #include "src/base/SkTime.h" |
9 | | |
10 | | #include <chrono> |
11 | | #include <ratio> |
12 | | |
13 | | #if !defined(__has_feature) |
14 | | #define __has_feature(x) 0 |
15 | | #endif |
16 | | |
17 | 0 | double SkTime::GetNSecs() { |
18 | | #if __has_feature(memory_sanitizer) |
19 | | // See skia:6504 |
20 | | struct timespec tp; |
21 | | clock_gettime(CLOCK_MONOTONIC, &tp); |
22 | | return tp.tv_sec * 1e9 + tp.tv_nsec; |
23 | | #else |
24 | 0 | auto now = std::chrono::steady_clock::now(); |
25 | 0 | std::chrono::duration<double, std::nano> ns = now.time_since_epoch(); |
26 | 0 | return ns.count(); |
27 | 0 | #endif |
28 | 0 | } |