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

Side by Side Diff: src/base/platform/time.h

Issue 1975093002: Version 5.2.303.1 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@5.2.303
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 unified diff | Download patch
« no previous file with comments | « include/v8-version.h ('k') | src/base/platform/time.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 are 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 // This is for internal use and testing. Ticks are in microseconds.
393 explicit ThreadTicks(int64_t ticks) : TimeBase(ticks) {}
394 };
395
396 } // namespace base 371 } // namespace base
397 } // namespace v8 372 } // namespace v8
398 373
399 #endif // V8_BASE_PLATFORM_TIME_H_ 374 #endif // V8_BASE_PLATFORM_TIME_H_
OLDNEW
« no previous file with comments | « include/v8-version.h ('k') | src/base/platform/time.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698