public inbox for dtrace@lists.linux.dev
 help / color / mirror / Atom feed
From: eugene.loh@oracle.com
To: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: [PATCH 3/3] test: Mimic dtrace arithmetic more closely for avg/stddev
Date: Thu,  1 May 2025 14:22:52 -0400	[thread overview]
Message-ID: <20250501182252.27772-3-eugene.loh@oracle.com> (raw)
In-Reply-To: <20250501182252.27772-1-eugene.loh@oracle.com>

From: Eugene Loh <eugene.loh@oracle.com>

The multicpus test checks that data from multiple CPUs is aggregated
properly.  Operations like avg() and stddev() require division.
DTrace uses integer division, while awk does not.

Change the awk check to truncate intermediate results after division.

In practice, intermediate results are typically integer values anyhow.
So the test has generally passed.  Non-integer values could arise if,
for example, CPUs are not numbered consecutively.  More typically,
there may be a problem that the profile probe is not firing on every
expected CPU.  So a test failure probably was a sign of a problem,
but that's a different problem, one beyond the scope of this test.

Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
---
 test/unittest/aggs/tst.multicpus.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/unittest/aggs/tst.multicpus.sh b/test/unittest/aggs/tst.multicpus.sh
index 50eeaae44..46c668867 100755
--- a/test/unittest/aggs/tst.multicpus.sh
+++ b/test/unittest/aggs/tst.multicpus.sh
@@ -79,10 +79,10 @@ gawk '
         # first we finish computing our estimates for avg and stddev
         # (the other results require no further action)
 
-        xavg /= xcnt;
+        xavg /= xcnt;            xavg = int(xavg);
 
-        xstm /= xcnt;
-        xstd /= xcnt;
+        xstm /= xcnt;            xstm = int(xstm);
+        xstd /= xcnt;            xstd = int(xstd);
         xstd -= xstm * xstm;
         xstd = int(sqrt(xstd));
 
-- 
2.43.5


  parent reply	other threads:[~2025-05-01 18:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-01 18:22 [PATCH 1/3] Cache per-CPU agg map IDs eugene.loh
2025-05-01 18:22 ` [PATCH 2/3] test: Convert tick-* probes to ioctl:entry for tst.trunc[quant].d eugene.loh
2025-07-16 13:21   ` Nick Alcock
2025-05-01 18:22 ` eugene.loh [this message]
2025-07-16 13:22   ` [DTrace-devel] [PATCH 3/3] test: Mimic dtrace arithmetic more closely for avg/stddev Nick Alcock
2025-07-16 19:51     ` Eugene Loh
2025-07-16 13:20 ` [DTrace-devel] [PATCH 1/3] Cache per-CPU agg map IDs Nick Alcock
2025-07-16 18:42   ` Eugene Loh
2025-07-16 19:10 ` Kris Van Hees
2025-07-16 20:05   ` Eugene Loh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250501182252.27772-3-eugene.loh@oracle.com \
    --to=eugene.loh@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox