Profiling an always run application

There is a client-server application which waits for a connection, do something and then close the connection. Maybe multiple incoming connections arrive.
I would like to profile the app for some seconds. I didn’t find such an option in the nvprof manual. Moreover, the existence of such an option may not be very helpful.
Assume the is an option for that

1- nvprof --runfor 10 --metrics A
2- nvprof --runfor 10 --metrics A, B, C, D

Providing more options in the metric, may increase the runtime. So, 10 seconds in the first command is not the same 10 seconds in the second command.

Any idea about that?

nvprof has a “profile all processes option”. As long as the process to be profiled is launched by the same user that launched nvprof, it should capture it. Rather than setting an option to run for a period of time, you can just end the nvprof session when you are done, with ctrl-C

alternatively nvprof has a timeout option.

Still there are some dark points for that.
As you know, using different number of metrics, will results in different runtimes. Assume, I give one metric. Then I wait for 5 seconds and then terminate the profiler. Assume in this 5 seconds, total kernel invocations are 1000.

Next, I give 3 metrics to nvprof and again cut the run after 5 seconds. Then question is, should I see 1000 invocations for this case or not?

I’m not sure you would see precisely 1000 invocations even if you ran the 5 second/one metric case twice. But since you have control over the timeout, you should be able to address that.