How to check inference time for a frame when using deepstream

You could add time stamp print before and after
sources/libs/nvdsinfer/nvdsinfer_context_impl.cpp::NvDsInferContextImpl::queueInputBatch
RETURN_NVINFER_ERROR(m_BackendContext->enqueueBuffer(backendBuffer,
*m_InferStream, m_InputConsumedEvent.get()),
“Infer context enqueue buffer failed”);

like this,

struct timeval start, stop;

gettimeofday(&start, NULL);

RETURN_NVINFER_ERROR(m_BackendContext->enqueueBuffer(backendBuffer,
                         *m_InferStream, m_InputConsumedEvent.get()),
    "Infer context enqueue buffer failed");

gettimeofday(&stop, NULL);
printf("time of infer takes: %ld us\n", (stop.tv_sec - start.tv_sec) * 1000000 + (stop.tv_usec - start.tv_usec));

recompile
export CUDA_VER=10.2
make -C libs/nvdsinfer/
backup original libnvds_infer.so under lib/
sudo cp libs/nvdsinfer/libnvds_infer.so lib/

1 Like