[libcamera-devel,2/2] utils: tracepoints: ipa call analyzer: Fix std dev calculation for single value
diff mbox series

Message ID 20210217092937.17167-2-paul.elder@ideasonboard.com
State New
Delegated to: Paul Elder
Headers show
Series
  • [libcamera-devel,1/2] utils: ipc: Generate tracepoints for IPA calls
Related show

Commit Message

Paul Elder Feb. 17, 2021, 9:29 a.m. UTC
Some IPA calls might only be called once, such as configure(), start(),
stop(), etc. This causes the analyzer to break as stddev() on a single
value is invalid. Set the stddev to zero if there is only one datapoint.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
---
 utils/tracepoints/analyze-ipa-trace.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Pinchart April 27, 2021, 7:07 a.m. UTC | #1
Hi Paul,

Thank you for the patch.

On Wed, Feb 17, 2021 at 06:29:37PM +0900, Paul Elder wrote:
> Some IPA calls might only be called once, such as configure(), start(),
> stop(), etc. This causes the analyzer to break as stddev() on a single

The function is called stdev, not stddev.

> value is invalid. Set the stddev to zero if there is only one datapoint.

The variable is stddev though.

> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  utils/tracepoints/analyze-ipa-trace.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/utils/tracepoints/analyze-ipa-trace.py b/utils/tracepoints/analyze-ipa-trace.py
> index 50fbbf42..cd7e9ffc 100755
> --- a/utils/tracepoints/analyze-ipa-trace.py
> +++ b/utils/tracepoints/analyze-ipa-trace.py
> @@ -58,7 +58,7 @@ def main(argv):
>      rows.append(['pipeline:function', 'min', 'max', 'mean', 'stddev'])
>      for k, v in samples.items():
>          mean = int(stats.mean(v))
> -        stddev = int(stats.stdev(v))
> +        stddev = int(stats.stdev(v)) if len(v) > 1 else 0
>          minv = min(v)
>          maxv = max(v)
>          rows.append([k, str(minv), str(maxv), str(mean), str(stddev)])

Patch
diff mbox series

diff --git a/utils/tracepoints/analyze-ipa-trace.py b/utils/tracepoints/analyze-ipa-trace.py
index 50fbbf42..cd7e9ffc 100755
--- a/utils/tracepoints/analyze-ipa-trace.py
+++ b/utils/tracepoints/analyze-ipa-trace.py
@@ -58,7 +58,7 @@  def main(argv):
     rows.append(['pipeline:function', 'min', 'max', 'mean', 'stddev'])
     for k, v in samples.items():
         mean = int(stats.mean(v))
-        stddev = int(stats.stdev(v))
+        stddev = int(stats.stdev(v)) if len(v) > 1 else 0
         minv = min(v)
         maxv = max(v)
         rows.append([k, str(minv), str(maxv), str(mean), str(stddev)])