catapult-project / catapult

Deprecated Catapult GitHub. Please instead use http://crbug.com "Speed>Benchmarks" component for bugs and https://chromium.googlesource.com/catapult for downloading and editing source code..
https://chromium.googlesource.com/catapult
BSD 3-Clause "New" or "Revised" License
1.91k stars 563 forks source link

trace2html -- events over a day scale? #4581

Open blezek opened 5 years ago

blezek commented 5 years ago

Been loving trace2html for visualization time data. The data I'd like to visualize relates to room utilization at a hospital, so the events have a date time stamp and need to range over day, week or even year durations.

As it stands, the only choice for time units are milliseconds and microseconds. Would it be feasible to adapt the code to use unix timestamps and display date / time information in the user interface?

My work around has been to use 1 day == 1 millisecond, with Jan 1 == 0 milliseconds. This works well, but would be nice to see the actual date on the X axis.

benshayden commented 5 years ago

Hello! I'd be happy to review a patch. The x-axis tick labels are generated here. You might be able to add support for setting displayTimeUnit to date or time to render the date or time.

blezek commented 5 years ago

@benshayden thanks for the pointers. I hacked together a dateTime mode and it works, however, the code seems to subtract the earliest timestamp to make the origin 0. So the first date is always Wed Dec 31 18:00:00 CST 1969 (the 0 unix timestamp).

Any ideas how to display actual values from the trace file?

benshayden commented 5 years ago

Try setting this.model_.importOptions.shiftWorldToZero = false; in trace_event_importer.html?

blezek commented 5 years ago

Hmm, doesn't seem to help... but perhaps I set it in the wrong place? Here's my code, sorry it's rather hacked together...

https://github.com/blezek/catapult/commit/b182c82664fecdb7f79f4bdd9aef83a7cc6dc179

Branch is: https://github.com/blezek/catapult/tree/datetime_in_timeline

Seems like it's fairly close. I'm not sure I can figure it out without investing a large amount of time, and I hate to bug you all the time...

blezek commented 5 years ago

Oops, my branch actually does work, if the timestamps are in ms (not seconds as I had them).

@benshayden, how should this feature be incorporated into the source? Ideally, the viewer would recognize the displayTimeUnit as ts and render the dates correctly, and not shiftWorldToZero. Not sure I have that working correctly, nor exactly where to plug in because the loading of data happens before the displayTimeUnit field is processed.

benshayden commented 5 years ago

You can add a special case in TraceEventImporter.storeDisplayTimeUnit like `if (unit === tr.b.TimeDisplayModes.dt) this.model.importOptions.shiftWorldToZero = false;` Beyond that, it would be easier to discuss the details in codereview after you upload a change to gerrit. See CONTRIBUTING.