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
* Option to time all IBA functions
All ImageBufAlgo functions (for now; other functionality may be added
to logging down the line) are outfitted with optional timers to count
the number of executions and total time spent for each.
This is enabled by a new global OIIO attribute "log_times", which can be
enabled and disabled at any time (for example, to only log a certain
phase of execution of an app).
The default is 0, meaning not to log -- and I believe that when turned
off, there is no added runtime cost (except for checking the flag once
per IBA function).
The initial default can be changed with the OPENIMAGEIO_LOG_TIMES
environment variable.
When log_times is nonzero, logging will occur, with a slight increase in
runtime expense to check the times and to lock and access the map that
stores all the running totals (stored separately, indexed by name). This
extra cost is probably not significant for whole-image operations such
as IBA calls, but it would not be an especially accurate way to time
fine-grained operations that work on one or a few pixels at a time.
The global getattribute() call may be used to retrieve "timing_report",
which will return a string containing a list of all the timing totals,
alphabetized by name, like this:
IBA::computePixelStats 2 0.003s (avg 1.34ms)
IBA::make_texture 1 0.074s (avg 74.05ms)
IBA::mul 8 0.002s (avg 0.30ms)
IBA::over 10 0.024s (avg 2.38ms)
IBA::resize 20 0.240s (avg 12.18ms)
IBA::zero 8 0.001s (avg 0.08ms)
If the log_times option has a value > 1 at the time that the program
terminates, the destructor of the timing data structure will
automatically print the timing report to stdout.
So, even for a program (that uses OIIO ImageBufAlgo internally) that has
no exposed option to retrieve and print the report, you can still find
out how it's spending its time by launching as
OPENIMAGEIO_LOG_TIMES=2 my_application
Some caveats to keep in mind:
* It's possible that in situations where one IBA function ends up
calling another, the time could be doubled-counted.
* This measures "wall clock time", so interpret carefully in the
presence of multithreading.
0 commit comments