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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 // This method never returns a null TimeTicks. | 353 // This method never returns a null TimeTicks. |
354 static TimeTicks HighResolutionNow(); | 354 static TimeTicks HighResolutionNow(); |
355 | 355 |
356 // Returns true if the high-resolution clock is working on this system. | 356 // Returns true if the high-resolution clock is working on this system. |
357 static bool IsHighResolutionClockWorking(); | 357 static bool IsHighResolutionClockWorking(); |
358 | 358 |
359 private: | 359 private: |
360 friend class time_internal::TimeBase<TimeTicks>; | 360 friend class time_internal::TimeBase<TimeTicks>; |
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 are 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 // This is for internal use and testing. Ticks are in microseconds. | |
393 explicit ThreadTicks(int64_t ticks) : TimeBase(ticks) {} | |
394 }; | |
jochen (gone - plz use gerrit)
2016/05/11 08:58:07
DISALLOW_COPY_AND_ASSIGN()
| |
395 | |
371 } // namespace base | 396 } // namespace base |
372 } // namespace v8 | 397 } // namespace v8 |
373 | 398 |
374 #endif // V8_BASE_PLATFORM_TIME_H_ | 399 #endif // V8_BASE_PLATFORM_TIME_H_ |
OLD | NEW |