Profiling a scripted/frozen models

Hi,
We want to profile the execution of scripted/frozen models.
I know that the profiler record_function op can be scripted, but I want to avoid having 2 versions of the model (one for profiling, and one for deployment).
Is there a suggested way to do this?