The contents api is pretty much unaware of what the kernel api is doing… about the only thing it could do would be to read off whatever a client (e.g. jupyterlab) claims in notebook metadata.
Are you trying to measure:
- the time from “press run” to “get pixels on screen”?
- the time the message spent in-flight to the server?
- the time the message spent in-flight between the server and the kernel?
- the actual execution time from
execute_request
being received to execute_response
or idle
or whatever comes back?
- the return trip?
- whatever the client claims?
Depending on how precise need it to be, you’d likely need to investigate where your notebook/jupyter_server is actually passing messages, or instrument the kernel itself. There are also some tools in the opencensus (e.g. GitHub - Quansight/jupyter-jaeger: @jupyter integration for @jaegertracing) realm that might work.