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

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>
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_
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