-
Notifications
You must be signed in to change notification settings - Fork 723
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
Core: log completion time if > 1.0 seconds per step #2345
Conversation
worlds/AutoWorld.py
Outdated
@@ -115,6 +119,10 @@ def call_single(multiworld: "MultiWorld", method_name: str, player: int, *args: | |||
logging.error(message) | |||
raise e | |||
else: | |||
taken = time.perf_counter()-start | |||
if taken > 0.1: | |||
perf_logger.info(f"Took {taken} seconds in {method} for player {player}, " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perf_logger.info(f"Took {taken} seconds in {method} for player {player}, " | |
perf_logger.info(f"Took {taken} seconds in {multiworld.worlds[player].__class__.__name__}'s {method.__name__} for player {player}.") |
maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe?
Sounds like you're trying to reinvent method.__qualname__
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be fine with cutting away the ram address, but you're cutting away too much. It also would lose consistency with the error reporting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having something shorter (be it qualname or something similar) would make the lines way shorter and easier to understand.
(It doesn't really have to be consistent with error reporting since it's not an error. It's actually something that a normal user might see during normal operation.)
Also, since all values are gonna be greater than 0.1, I'd suggest formatting the numbers to two decimal places; again, to make it easier for the reader to parse the relevant information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tried qualname? Because all it is is "World.set_rules", no matter which world
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange. I had tested it.
Here's the output I get with {method.__qualname__}
(and the threshold removed so that all stages will be printed).
For me it only printed World
if it really executed the method of the base class where it was not overridden in the specific world. (And these should never go over the threshold in practice, since they are usually just pass
)
(For reference, this was 3.8 on Windows)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's unfortunate. Maybe we have to do something more verbose after all.
|
1 2 |
worlds/AutoWorld.py
Outdated
@@ -103,10 +106,23 @@ def __new__(mcs, name: str, bases: Tuple[type, ...], dct: Dict[str, Any]) -> Aut | |||
return new_class | |||
|
|||
|
|||
def _timed_call(method: Callable, *args: Any, multiworld: "MultiWorld" = None, player: int = None) -> Any: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def _timed_call(method: Callable, *args: Any, multiworld: "MultiWorld" = None, player: int = None) -> Any: | |
def _timed_call(method: Callable[..., Any], *args: Any, | |
multiworld: Optional["MultiWorld"] = None, player: Optional[int] = None) -> Any: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would have preferred a cleaner output (see comment); functionality is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm. With >1sec this should be fine on main.
What is this fixing or adding?
adds rudimentary performance logging, for longer (async) generations it also gives you a bit of a progress/alive signal.
I consider this the first step of multiple towards having some more useful benchmarking.
How was this tested?
with a few thousand worlds
If this makes graphical changes, please attach screenshots.