# How to measure PGIE latency?

**URL:** <https://forums.developer.nvidia.com/t/how-to-measure-pgie-latency/111829>\
**Category:** DeepStream SDK\
**Created:** [February 11, 2020, 4:59pm UTC](https://forums.developer.nvidia.com/t/how-to-measure-pgie-latency/111829 "2020-02-11T16:59:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fbrughi](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@fbrughi](https://forums.developer.nvidia.com/u/fbrughi)\
**Post date:** [February 11, 2020, 4:59pm UTC](https://forums.developer.nvidia.com/t/how-to-measure-pgie-latency/111829/1 "2020-02-11T16:59:39Z")

</div>

Hello,  
the title is pretty self-explanatory, I need to have a reliable measure of the time it takes to a batch to pass thru a PGIE element;

which is the recommended strategy?

thanks in advance,

f

---

<div class="post-metadata">

**Author:** ![ChrisDing](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/chrisding/32/14043_2.png) [@ChrisDing](https://forums.developer.nvidia.com/u/ChrisDing)\
**Post date:** [February 12, 2020, 7:46am UTC](https://forums.developer.nvidia.com/t/how-to-measure-pgie-latency/111829/2 "2020-02-12T07:46:23Z")

</div>

Cuda has the bandwidth test sample to test host to device and device to host bandwidth. /usr/local/cuda/samples/1\_Utilities/bandwidthTest

---

<div class="post-metadata">

**Author:** ![fbrughi](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@fbrughi](https://forums.developer.nvidia.com/u/fbrughi)\
**Post date:** [February 12, 2020, 2:24pm UTC](https://forums.developer.nvidia.com/t/how-to-measure-pgie-latency/111829/3 "2020-02-12T14:24:34Z")

</div>

Hi,  
thanks for replying;

maybe I didn’t express myself clearly;  
I need a reliable measure of the inference time;  
the h2d and d2h memcopy are not part of this analysis;

I found this API searching within your documentation  
[https://docs.nvidia.com/metropolis/deepstream/4.0/dev-guide/DeepStream\_Development\_Guide/baggage/group\_\_ee\_\_nvlatency\_\_group.html](https://docs.nvidia.com/metropolis/deepstream/4.0/dev-guide/DeepStream_Development_Guide/baggage/group __ee__ nvlatency__group.html)

I use the function

```auto
num_sources_in_batch = nvds_measure_buffer_latency(buf, latency_info);

```

inside a probe attached to the primary sink pad, where latency info is allocated like this

```auto
NvDsFrameLatencyInfo *latency_info = (NvDsFrameLatencyInfo *) malloc(batch_size * sizeof(NvDsFrameLatencyInfo));

```

the problem is that when the probe is triggered and the function above is executed I get a segmentation fault; am I missing any step? I could not find any code sample of how to use this API

thanks again,

f

---

<div class="post-metadata">

**Author:** ![ChrisDing](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/chrisding/32/14043_2.png) [@ChrisDing](https://forums.developer.nvidia.com/u/ChrisDing)\
**Post date:** [February 13, 2020, 1:18am UTC](https://forums.developer.nvidia.com/t/how-to-measure-pgie-latency/111829/4 "2020-02-13T01:18:46Z")

</div>

Can you refer to

sources/apps/sample\_apps/deepstream-app/deepstream\_app.c → latency\_measurement\_buf\_prob()

---

<div class="post-metadata">

**Author:** ![ChrisDing](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/chrisding/32/14043_2.png) [@ChrisDing](https://forums.developer.nvidia.com/u/ChrisDing)\
**Post date:** [February 18, 2020, 11:11am UTC](https://forums.developer.nvidia.com/t/how-to-measure-pgie-latency/111829/5 "2020-02-18T11:11:12Z")

</div>

Ensure that Jetson clocks are set high. Run these commands to set Jetson clocks high.  
$ sudo nvpmodel -m --for MAX perf and power mode is 0  
$ sudo jetson\_clocks

[https://docs.nvidia.com/metropolis/deepstream/plugin-manual/index.html#page/DeepStream\_Plugin\_Manual%2Fdeepstream\_plugin\_troubleshooting.html](https://docs.nvidia.com/metropolis/deepstream/plugin-manual/index.html#page/DeepStream_Plugin_Manual%2Fdeepstream_plugin_troubleshooting.html) → The DeepStream application is running slowly

To enable frame latency measurement, run this command on the console:  
$ export NVDS\_ENABLE\_LATENCY\_MEASUREMENT=1  
•To enable latency for all plugins, run this command on the console:  
$ export NVDS\_ENABLE\_COMPONENT\_LATENCY\_MEASUREMENT=1  
Using deepstream app, for latency measurement user should use RTSP or USB live sources and not file based

---

<div class="post-metadata">

**Author:** ![TomNVIDIA](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/tomnvidia/32/14181_2.png) [@TomNVIDIA](https://forums.developer.nvidia.com/u/TomNVIDIA)\
**Post date:** [October 12, 2021, 4:18pm UTC](https://forums.developer.nvidia.com/t/how-to-measure-pgie-latency/111829/6 "2021-10-12T16:18:27Z")

</div>

Closed on October 12, 2021, 4:18pm UTC


