Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_BASE_PLATFORM_TIME_H_ | 5 #ifndef V8_BASE_PLATFORM_TIME_H_ |
| 6 #define V8_BASE_PLATFORM_TIME_H_ | 6 #define V8_BASE_PLATFORM_TIME_H_ |
| 7 | 7 |
| 8 #include <ctime> | 8 #include <ctime> |
| 9 #include <iosfwd> | 9 #include <iosfwd> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 | 361 |
| 362 // Please use Now() to create a new object. This is for internal use | 362 // Please use Now() to create a new object. This is for internal use |
| 363 // and testing. Ticks is in microseconds. | 363 // and testing. Ticks is in microseconds. |
| 364 explicit TimeTicks(int64_t ticks) : TimeBase(ticks) {} | 364 explicit TimeTicks(int64_t ticks) : TimeBase(ticks) {} |
| 365 }; | 365 }; |
| 366 | 366 |
| 367 inline TimeTicks operator+(const TimeDelta& delta, const TimeTicks& ticks) { | 367 inline TimeTicks operator+(const TimeDelta& delta, const TimeTicks& ticks) { |
| 368 return ticks + delta; | 368 return ticks + delta; |
| 369 } | 369 } |
| 370 | 370 |
| 371 | |
| 372 // ThreadTicks ---------------------------------------------------------------- | |
| 373 | |
| 374 // Represents a clock, specific to a particular thread, than runs only while the | |
| 375 // thread is running. | |
| 376 class ThreadTicks final : public time_internal::TimeBase<ThreadTicks> { | |
| 377 public: | |
| 378 ThreadTicks() : TimeBase(0) {} | |
| 379 | |
| 380 // Returns true if ThreadTicks::Now() is supported on this system. | |
| 381 static bool IsSupported(); | |
| 382 | |
| 383 // Returns thread-specific CPU-time on systems that support this feature. | |
| 384 // Needs to be guarded with a call to IsSupported(). Use this timer | |
| 385 // to (approximately) measure how much time the calling thread spent doing | |
| 386 // actual work vs. being de-scheduled. May return bogus results if the thread | |
| 387 // migrates to another CPU between two calls. Returns an empty ThreadTicks | |
| 388 // object until the initialization is completed. | |
| 389 static ThreadTicks Now(); | |
| 390 | |
| 391 private: | |
| 392 // Please use Now() or GetForThread() to create a new object. This is for | |
|
fmeawad
2016/05/09 23:22:33
I cannot find a GetForThread method in the API?
lpy
2016/05/09 23:51:15
Done.
| |
| 393 // internal use and testing. Ticks is in microseconds. | |
| 394 explicit ThreadTicks(int64_t ticks) : TimeBase(ticks) {} | |
| 395 }; | |
| 396 | |
| 371 } // namespace base | 397 } // namespace base |
| 372 } // namespace v8 | 398 } // namespace v8 |
| 373 | 399 |
| 374 #endif // V8_BASE_PLATFORM_TIME_H_ | 400 #endif // V8_BASE_PLATFORM_TIME_H_ |
| OLD | NEW |