imageworks/OpenShadingLanguage — pull request #418 by lgritz (2014-09-29 21:59:48+00:00)
Title: Basic shader profiling

ShadingSystem::attribute ("profile", 1) turns on profiling, which will attempt to time the total amount of runtime spent actually executing shaders. This will be included in the runtime statistics, both as a total as well as listing the "top 5" individual shader groups that accounted for the most time.

Profiling isn't free -- it adds a small runtime cost, because it must do timer queries before and after the main entry point to every shader invocation, so only turn it on if you are interested in the results. (That said, it's surprisingly inexpensive -- doesn't seem to throw runtime off by more than 1%.)

Example output looks like this:

Execution profile:
Total shader execution time: 43.32s
Most expensive shader groups:
8.08s sky_barry/material
3.48s sky/material
2.39s sam/sam_head_bangs_safari.hair
1.97s flnt/flnt_head_base_def.hair
1.97s sam_accessories/sam_pony_base_safari.hair