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

Issue 23295034: Add Chromium-style TimeDelta, Time and TimeTicks classes, and a new ElapsedTimer class. (Closed)

Created:
7 years, 3 months ago by Benedikt Meurer
Modified:
7 years, 3 months ago
CC:
v8-dev, tfarina
Visibility:
Public.

Description

Add Chromium-style TimeDelta, Time and TimeTicks classes, and a new ElapsedTimer class. These classes are meant to replace OS::Ticks() and OS::TimeCurrentMillis(), which are broken in several ways. The ElapsedTimer class implements a stopwatch using TimeTicks::HighResNow() for high resolution, monotonic timing. Also fix the CpuProfile::GetStartTime() and CpuProfile::GetEndTime() methods to actually return the time relative to the unix epoch as stated in the documentation (previously that was relative to some arbitrary point in time, i.e. boot time). BUG=v8:2853 R=machenbach@chromium.org, yurys@chromium.org Committed: https://code.google.com/p/v8/source/detail?r=16388 Committed: https://code.google.com/p/v8/source/detail?r=16390

Patch Set 1 #

Patch Set 2 : REBASE #

Patch Set 3 : Fix windows build. #

Total comments: 2

Patch Set 4 : REBASE #

Total comments: 6

Patch Set 5 : REBASE #

Patch Set 6 : Fix second assertion in IsStarted(). #

Patch Set 7 : Fix typo #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+1256 lines, -255 lines) Patch
M src/api.cc View 1 2 3 4 1 chunk +2 lines, -2 lines 0 comments Download
M src/compiler.h View 5 chunks +13 lines, -13 lines 0 comments Download
M src/compiler.cc View 1 2 5 chunks +8 lines, -11 lines 0 comments Download
M src/counters.h View 2 chunks +3 lines, -6 lines 0 comments Download
M src/counters.cc View 2 chunks +3 lines, -5 lines 0 comments Download
M src/cpu-profiler.h View 2 chunks +2 lines, -2 lines 0 comments Download
M src/cpu-profiler.cc View 1 3 chunks +7 lines, -5 lines 0 comments Download
M src/deoptimizer.cc View 2 chunks +3 lines, -2 lines 0 comments Download
M src/hydrogen.h View 1 2 3 1 chunk +11 lines, -15 lines 0 comments Download
M src/hydrogen.cc View 1 2 3 4 3 chunks +18 lines, -18 lines 0 comments Download
M src/lithium-allocator.cc View 1 chunk +1 line, -1 line 0 comments Download
M src/log.h View 2 chunks +2 lines, -1 line 0 comments Download
M src/log.cc View 1 2 5 chunks +5 lines, -6 lines 0 comments Download
M src/optimizing-compiler-thread.h View 3 chunks +4 lines, -5 lines 0 comments Download
M src/optimizing-compiler-thread.cc View 4 chunks +7 lines, -9 lines 0 comments Download
M src/parser.cc View 4 chunks +12 lines, -6 lines 0 comments Download
M src/platform.h View 1 2 3 4 1 chunk +0 lines, -4 lines 0 comments Download
M src/platform-linux.cc View 1 chunk +1 line, -1 line 0 comments Download
M src/platform-macos.cc View 1 chunk +1 line, -1 line 0 comments Download
M src/platform-openbsd.cc View 1 chunk +1 line, -1 line 0 comments Download
M src/platform-posix.cc View 1 2 1 chunk +1 line, -13 lines 0 comments Download
M src/platform-win32.cc View 1 2 11 chunks +21 lines, -105 lines 0 comments Download
M src/profile-generator.h View 1 2 3 4 3 chunks +6 lines, -4 lines 0 comments Download
M src/profile-generator.cc View 1 2 3 4 5 6 2 chunks +3 lines, -3 lines 0 comments Download
A src/time/elapsed-timer.h View 1 2 3 4 5 1 chunk +120 lines, -0 lines 2 comments Download
A src/time/time.h View 1 chunk +381 lines, -0 lines 0 comments Download
A src/time/time.cc View 1 2 1 chunk +483 lines, -0 lines 0 comments Download
M test/cctest/cctest.gyp View 1 1 chunk +1 line, -0 lines 0 comments Download
M test/cctest/test-cpu-profiler.cc View 5 chunks +9 lines, -11 lines 0 comments Download
A test/cctest/test-time.cc View 1 2 1 chunk +116 lines, -0 lines 0 comments Download
M tools/gyp/v8.gyp View 1 2 6 chunks +11 lines, -5 lines 0 comments Download

Messages

Total messages: 13 (0 generated)
Benedikt Meurer
The initial part of the time related cleanup I mentioned. All required bits for the ...
7 years, 3 months ago (2013-08-26 12:07:23 UTC) #1
yurys
Patch set #2 doesn't compile on Windows: 2>..\..\src\platform-win32.cc(249): error C2011: 'v8::internal::Time' : 'class' type redefinition ...
7 years, 3 months ago (2013-08-27 08:06:14 UTC) #2
Benedikt Meurer
Ups, I'll fix that.
7 years, 3 months ago (2013-08-27 08:26:00 UTC) #3
Benedikt Meurer
On 2013/08/27 08:26:00, Benedikt Meurer wrote: > Ups, I'll fix that. Done.
7 years, 3 months ago (2013-08-27 11:08:02 UTC) #4
Benedikt Meurer
On 2013/08/27 11:08:02, Benedikt Meurer wrote: > On 2013/08/27 08:26:00, Benedikt Meurer wrote: > > ...
7 years, 3 months ago (2013-08-27 11:08:55 UTC) #5
yurys
lgtm https://codereview.chromium.org/23295034/diff/21001/test/cctest/test-cpu-profiler.cc File test/cctest/test-cpu-profiler.cc (left): https://codereview.chromium.org/23295034/diff/21001/test/cctest/test-cpu-profiler.cc#oldcode422 test/cctest/test-cpu-profiler.cc:422: int64_t time_before_profiling = i::OS::Ticks(); You can take Time::NowFromSystemTime() ...
7 years, 3 months ago (2013-08-28 07:04:21 UTC) #6
Benedikt Meurer
https://codereview.chromium.org/23295034/diff/21001/test/cctest/test-cpu-profiler.cc File test/cctest/test-cpu-profiler.cc (left): https://codereview.chromium.org/23295034/diff/21001/test/cctest/test-cpu-profiler.cc#oldcode422 test/cctest/test-cpu-profiler.cc:422: int64_t time_before_profiling = i::OS::Ticks(); On 2013/08/28 07:04:21, Yury Semikhatsky ...
7 years, 3 months ago (2013-08-28 07:06:31 UTC) #7
Michael Achenbach
lgtm with nit https://codereview.chromium.org/23295034/diff/15001/src/time/elapsed-timer.h File src/time/elapsed-timer.h (right): https://codereview.chromium.org/23295034/diff/15001/src/time/elapsed-timer.h#newcode69 src/time/elapsed-timer.h:69: ASSERT(start_ticks_.IsNull() || started_); Is the second ...
7 years, 3 months ago (2013-08-28 10:47:17 UTC) #8
Benedikt Meurer
Nits addressed. https://codereview.chromium.org/23295034/diff/15001/src/time/elapsed-timer.h File src/time/elapsed-timer.h (right): https://codereview.chromium.org/23295034/diff/15001/src/time/elapsed-timer.h#newcode69 src/time/elapsed-timer.h:69: ASSERT(start_ticks_.IsNull() || started_); On 2013/08/28 10:47:17, machenbach ...
7 years, 3 months ago (2013-08-28 10:58:36 UTC) #9
Benedikt Meurer
Committed patchset #6 manually as r16388.
7 years, 3 months ago (2013-08-28 10:59:37 UTC) #10
Benedikt Meurer
Committed patchset #7 manually as r16390.
7 years, 3 months ago (2013-08-28 11:06:40 UTC) #11
tfarina
https://codereview.chromium.org/23295034/diff/35001/src/time/elapsed-timer.h File src/time/elapsed-timer.h (right): https://codereview.chromium.org/23295034/diff/35001/src/time/elapsed-timer.h#newcode79 src/time/elapsed-timer.h:79: ASSERT(IsStarted()); why all the implementations are in the header ...
7 years, 3 months ago (2013-09-07 04:15:40 UTC) #12
Benedikt Meurer
7 years, 3 months ago (2013-09-09 05:55:17 UTC) #13
Message was sent while issue was closed.
https://codereview.chromium.org/23295034/diff/35001/src/time/elapsed-timer.h
File src/time/elapsed-timer.h (right):

https://codereview.chromium.org/23295034/diff/35001/src/time/elapsed-timer.h#...
src/time/elapsed-timer.h:79: ASSERT(IsStarted());
On 2013/09/07 04:15:40, tfarina wrote:
> why all the implementations are in the header file? does that brings any
> advantage over declaring in the header and implementing in the source file? if
> yes, how did you measure it?

The implementation is trivial, one method invocation and one subtraction
(inlined from TimeTicks - operator). We usually just inline stuff like this in
the header.

Powered by Google App Engine
This is Rietveld 408576698