google / perfetto

Performance instrumentation and tracing for Android, Linux and Chrome (read-only mirror of https://android.googlesource.com/platform/external/perfetto/)
https://www.perfetto.dev
Apache License 2.0
2.82k stars 351 forks source link

Let users set the displayed time range #766

Open chiphogg opened 6 months ago

chiphogg commented 6 months ago

I use perfetto to iterate on improving C++ compile times for individual files. It would be really satisfying to be able to see the "jump" once I finally break through and score a significant speedup. But perfetto automatically scales the data so that it consumes the full width of the UI. This means that when I switch to the new-and-improved time trace, it doesn't look shorter; it just looks "different".

I searched previous issues for "range", and found #737. I don't really understand javascript, but after some hacking, I was able to come up with this snippet, which I could input into the javascript console (F12), and set the range to 50 seconds:

window.postMessage({perfetto: {timeStart: 0n, timeEnd: 50000000000n,},}, "https://ui.perfetto.dev")

The problem is that perfetto appears to restrict the display so that the data never consumes less than the full width. In particular, if I open a time trace that took less than 50 seconds overall and apply that command, it simply scales to the full width. For manual zooming, with w and s, this makes a lot of sense and is really convenient: it makes it super easy to just zoom out and see all of the data, without "overzooming". But if the user is inputting precise values, I don't think that restriction should apply.

(It'd also be nice if that inputting of precise values could get some first class UI support, but if we could just remove the zoom limit for this use case, then I could live with the javascript console!)

primiano commented 6 months ago

Fair request. As long as we don't over-zoom when the use presses W/S or uses the scroll wheel, i'm supportive of this change.

@chiphogg feel free to drop a patch! Thanks

chiphogg commented 6 months ago

I'd be happy to, but I have no idea how to develop in javascript, and I'm not familiar with the structure of the project. That said, if some other javascript-savvy person stumbles on this issue, please feel free to put up a patch in my place!