usnistgov / fipy

FiPy is a Finite Volume PDE solver written in Python
http://pages.nist.gov/fipy/en/latest
Other
505 stars 148 forks source link

Introduce Timer context manager #995

Closed guyer closed 8 months ago

guyer commented 8 months ago

Originally tried to make Timer() do logging, too, but I couldn't figure out how to get it to log in the correct scope. Separating timing from logging substantially simplifies the logic at a modest cost in LoC at point of use.

wd15 commented 8 months ago

LGTM, I get similar to @tkphd.

I see that the Timer context is being repeated in many different places. Suggests that the context should be in a single place and then what's inside the context should be what is unique to each subclass.

guyer commented 8 months ago

I see that the Timer context is being repeated in many different places. Suggests that the context should be in a single place and then what's inside the context should be what is unique to each subclass.

I see your point. The thing is that what's inside the context is highly dependent on the broader context of ._solve_(). I guess that could be stored as a bunch of Solver member variables... I'll think about this in my broader solver refactorization.