You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To time each component (very important in tweaking parameters for large scale computing), the best way I am aware so far is the with context manager like in the code. But when there are too many to time, it becomes ugly. It really hurts the readability. Is there a way to simplify this? (e.g., can one define a special syntax in comments, and convert all those comments through a single context manager outside with options to activate or not? Or is there a good profiler that suits the purpose?)
The text was updated successfully, but these errors were encountered:
You can write a spawner class for Timer, you could give it the attributes that are commonly reused and effectively make the lines shorter.
Another thing that could be done is writing a simple wrapper for the timer stuff.
Would mean tho that you then need to put everything in lamda functions.
A wrapper for that would look something like that.
Awesome! Thanks for the tips. Need to think about it.
Is it generally a bad idea to modify codes when using context manager? Ideally I would like to mark the lines I want to time in comments and only time it during profiling/debugging. In actual deployment/experiment I don't really care about those timer records.
So far i know you can remove it.
Right now i do not really know tho how to remove it via variable.
Using the spawner method you could make passthrough objects if an attribute is set, but i don't know if it's recommendable.
To time each component (very important in tweaking parameters for large scale computing), the best way I am aware so far is the
with
context manager like in the code. But when there are too many to time, it becomes ugly. It really hurts the readability. Is there a way to simplify this? (e.g., can one define a special syntax in comments, and convert all those comments through a single context manager outside with options to activate or not? Or is there a good profiler that suits the purpose?)The text was updated successfully, but these errors were encountered: