time: improve time datastructure
Review Request #425 - Created Jan. 13, 2011 and submitted
| Information | |
|---|---|
| Nathan Binkert | |
| gem5 | |
| Reviewers | |
| Default | |
| ali, gblack, nate, stever | |
time: improve time datastructure Use posix clock functions (and librt) if it is available. Inline a bunch of functions and implement more operators.
quick regressions pass
Posted (Jan. 13, 2011, 2:45 p.m.)
Looks pretty good, and thanks!
-
src/base/time.hh (Diff revision 1) -
Maybe define a constant for this? It's hard to count out that many zeros reliably.
-
src/base/time.cc (Diff revision 1) -
Are you sure you want to use CLOCK_MONOTONIC here? My book says this is in reference to an "unspecified point in the past" and is for a clock source that can't jump around if, for instance, somebody updates the system time. There isn't necessarily anything wrong with that, but I don't think that's what gettimeofday does. If you want to really have a gettimeofday substitute, I think you want to use CLOCK_REALTIME, although that's mostly just a relatively uninformed interpretation of what's in the book and may be wrong.
Posted (Jan. 13, 2011, 3:50 p.m.)
-
src/base/time.hh (Diff revision 1) -
heh, but the constant will have that many zeroes too! I could use 1000*1000*1000 if you prefer. I'll figure something out.
-
src/base/time.cc (Diff revision 1) -
Oh, I used whatever you used. CLOCK_REALTIME is fine too, though I guess I never really cared about the fact that I could print the time as a string. I am generally more interested in using it for measuring how long things take. I hesitate to make this code more complex, but I guess I could create a set_wallclock() func that does one and a set_timer() that does the other.
Review request changed
Updated (Jan. 14, 2011, 5:32 a.m.)
Description: |
|
||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 2 (+235 -141) |
