-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add @timeline
macro? (macro to show file/line info with timing results)
#44375
Comments
Perhaps this would make more sense as a feature for https://github.com/KristofferC/TimerOutputs.jl ? I don't think it currently keeps track of location info, but shouldn't be hard to add. |
That's a possibility. I would prefer having it in |
You can already show file:line, although it requires a little bit of manual work:
|
Ah, I hadn't thought about using those macros (because using them in this context wasn't possible until now). What I have to type is a bit more verbose than I would like (and literally every character requires the shift key on my keyboard 😂), but at least it's simple. The output does become a bit cumbersome if the file path is long, especially when there is compilation and GC time to report. But I think this solution will suffice for now. |
#42431 adds a
@showtime
macro to show the expression being timed along with the timing results. Would it also be worth adding a@timeline
macro? (Ideas for alternative names for the macro are also welcome.)I generally find myself having timing statements scattered about my code (usually when debugging), so to me having file and line info is more useful than just showing the timed expression. With #42431 I can now manually annotate each timing statement with file/line info, but if I modify my code I have to manually update the line numbers.
I wrote my own
@timeline
macro here, but it would be more convenient if (an updated version of) it was inBase
. (I had to copy-paste Julia's@time
code to allow nested calls to@timeline
to print properly, but with #42431 I think I can avoid that code duplication.) I also printed the file/line info in green to more easily distinguish between location and timing information, but that's not strictly necessary. (Would it be possible to do that without changingBase.time_print
to useprintstyled
?)When printing file info, there's also the question of whether to print the full path, or just the file name, or something in between. I included a
depth
argument in@timeline
to allow the user to specify how far up the file path to display (default is to print just the file name for brevity).I'd be happy to submit a PR for a
@timeline
macro if people think this is a good idea.The text was updated successfully, but these errors were encountered: