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

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

Issue 1959103004: Implement CPU time for OS X and POSIX. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.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 unified diff | Download patch
« no previous file with comments | « no previous file | src/base/platform/time.cc » ('j') | src/base/platform/time.cc » ('J')
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>
11 11
12 #include "src/base/bits.h" 12 #include "src/base/bits.h"
13 #include "src/base/macros.h" 13 #include "src/base/macros.h"
14 #include "src/base/safe_math.h"
fmeawad 2016/05/09 21:50:32 Unrelated to this CL?
lpy 2016/05/09 22:13:41 Done.
15 14
16 // Forward declarations. 15 // Forward declarations.
17 extern "C" { 16 extern "C" {
18 struct _FILETIME; 17 struct _FILETIME;
19 struct mach_timespec; 18 struct mach_timespec;
20 struct timespec; 19 struct timespec;
21 struct timeval; 20 struct timeval;
22 } 21 }
23 22
24 namespace v8 { 23 namespace v8 {
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 360
362 // Please use Now() to create a new object. This is for internal use 361 // Please use Now() to create a new object. This is for internal use
363 // and testing. Ticks is in microseconds. 362 // and testing. Ticks is in microseconds.
364 explicit TimeTicks(int64_t ticks) : TimeBase(ticks) {} 363 explicit TimeTicks(int64_t ticks) : TimeBase(ticks) {}
365 }; 364 };
366 365
367 inline TimeTicks operator+(const TimeDelta& delta, const TimeTicks& ticks) { 366 inline TimeTicks operator+(const TimeDelta& delta, const TimeTicks& ticks) {
368 return ticks + delta; 367 return ticks + delta;
369 } 368 }
370 369
370
371 // ThreadTicks ----------------------------------------------------------------
372
373 // Represents a clock, specific to a particular thread, than runs only while the
374 // thread is running.
375 class ThreadTicks final : public time_internal::TimeBase<ThreadTicks> {
376 public:
377 ThreadTicks() : TimeBase(0) {}
378
379 // Returns true if ThreadTicks::Now() is supported on this system.
380 static bool IsSupported();
381
382 // Returns thread-specific CPU-time on systems that support this feature.
383 // Needs to be guarded with a call to IsSupported(). Use this timer
384 // to (approximately) measure how much time the calling thread spent doing
385 // actual work vs. being de-scheduled. May return bogus results if the thread
386 // migrates to another CPU between two calls. Returns an empty ThreadTicks
387 // object until the initialization is completed.
388 static ThreadTicks Now();
389
390 private:
391 // Please use Now() or GetForThread() to create a new object. This is for
392 // internal use and testing. Ticks is in microseconds.
393 explicit ThreadTicks(int64_t ticks) : TimeBase(ticks) {}
394 };
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_
OLDNEW
« no previous file with comments | « no previous file | src/base/platform/time.cc » ('j') | src/base/platform/time.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698