Hello,
If what you want to measure happens to be the execution of a parloop kernel, since they are in C, you can just add the macros there. To modify generated code manually, locate the kernel in the PyOP2 disk cache, modify the C file, recompile the modified C file with the instructions in the .log file, which will create a .so.tmp file, which is to replace the .so file. Once you have done this, at the next execution Firedrake will pick up your manually modified .so file.
If this is not sufficient, you could use Cython to write a Python context manager which refers to the appropriate C macros in its __enter__ and __exit__ methods.
Regards,
Miklos