All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim Cromie <jim.cromie@domain.hid>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: xenomai-core <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] Re: xeno-load: line 182: 2794 Floating	point	exception$suflag $* $cmdargs
Date: Mon, 21 Aug 2006 11:31:50 -0600	[thread overview]
Message-ID: <44E9EE06.8010303@domain.hid> (raw)
In-Reply-To: <17641.43126.189924.769218@domain.hid>

[-- Attachment #1: Type: text/plain, Size: 1068 bytes --]

Gilles Chanteperdrix wrote:
>
> You likely have a division by 0 because nsamples is 0. nsamples come
> from the numeric argument of the -n option, and I think you do not pass
> a numeric argument to -n, so atoi returns 0.
>
>   

Yup, thats it.

prog was getting -n -l 1000
-l is illegal option, but -n needs an arg, and -l became it, and 
converts to 0.
so no error caused by -l either !

attached patch does:

xeno-test:     drop most options passed to switchbench,, added -h
switchbench:
    - sanity check on nsamples.
    - 1st column labels on Histogram
    - compute statistics (sort of -  I couldnt get 'sqrt' to link..)



Also, I recall at one time, one of the testsuite progs was intended
to be run in either xenomai, or in plain kernel.
Is this still the case ?
Or has it been superseded, forex by latency's  -t [0-3] options ?
If it is, should xeno-test run them that way as well ?

FWIW, I always found that distinction
too mysterious to not have an explicit option, along with errors
explaining 'insufficient privilege to run in RT-mode' as necessary.


[-- Attachment #2: patch.swbench --]
[-- Type: text/plain, Size: 2560 bytes --]

Index: scripts/xeno-test.in
===================================================================
--- scripts/xeno-test.in	(revision 1487)
+++ scripts/xeno-test.in	(working copy)
@@ -200,7 +200,7 @@
 	loudly ./run -- -T 120 $XENOT_SWITCHTEST '# switchtest'
     )
     (	cd `dirname $0`/../testsuite/switchbench
-	loudly ./run -- -p 10 -n -l 1000 $XENOT_SWITCHBENCH '# switchbench'
+	loudly ./run -- -h $XENOT_SWITCHBENCH '# switchbench'
     )
     (	cd `dirname $0`/../testsuite/cyclic
 	loudly ./run -- -p 10 -n -l 1000 $XENOT_CYCLIC '# cyclictest'
Index: src/testsuite/switchbench/switchbench.c
===================================================================
--- src/testsuite/switchbench/switchbench.c	(revision 1487)
+++ src/testsuite/switchbench/switchbench.c	(working copy)
@@ -8,6 +8,7 @@
 #include <sys/mman.h>
 #include <unistd.h>
 #include <stdlib.h>
+#include <math.h>
 #include <stdio.h>
 #include <string.h>
 #include <signal.h>
@@ -43,17 +44,42 @@
 	histogram[inabs < HISTOGRAM_CELLS ? inabs : HISTOGRAM_CELLS - 1]++;
 }
 
-void dump_histogram(void)
+void dump_stats(double sum, int total_hits)
 {
-       int n;
+	int n;
+	double avg, variance = 0;
 
-       for (n = 0; n < HISTOGRAM_CELLS; n++) {
-               long hits = histogram[n];
-               if (hits)
-                       fprintf(stderr, "%d - %d us: %ld\n", n, n + 1, hits);
-       }
+	avg = sum / total_hits;
+	for (n = 0; n < HISTOGRAM_CELLS; n++) {
+		long hits = histogram[n];
+		if (hits)
+			variance += hits * (n-avg) * (n-avg);
+	}
+
+	/* compute std-deviation (unbiased form) */
+	variance /= total_hits - 1;
+	// variance = sqrt(variance);
+	
+	printf("HSS| %9d| %10.3f| %10.3f\n", total_hits, avg, variance);
 }
 
+void dump_histogram(void)
+{
+	int n, total_hits = 0;
+	double sum = 0;
+	fprintf(stderr, "---|---range-|---samples\n");
+	for (n = 0; n < HISTOGRAM_CELLS; n++) {
+		long hits = histogram[n];
+		if (hits) {
+			total_hits += hits;
+			sum += n * hits;
+			fprintf(stderr, "HSD| %d - %d | %10ld\n",
+				n, n + 1, hits);
+		}
+	}
+	dump_stats(sum, total_hits);
+}
+
 void event(void *cookie)
 {
        int err;
@@ -180,8 +206,14 @@
                }
 
        if (sampling_period == 0)
-               sampling_period = 100000;       /* ns */
+               sampling_period = 100000;	/* ns */
 
+       if (nsamples <= 0) {
+	       fprintf(stderr, "disregarding -n <%lld>, using -n <100> us\n",
+		       nsamples);
+               nsamples = 100000;		/* ns */
+       }
+
        signal(SIGINT, SIG_IGN);
        signal(SIGTERM, SIG_IGN);
 

  reply	other threads:[~2006-08-21 17:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-21  1:53 [Xenomai-core] xeno-load: line 182: 2794 Floating point exception$suflag $* $cmdargs Jim Cromie
2006-08-21  6:42 ` [Xenomai-core] " Jim Cromie
2006-08-21  6:56   ` Philippe Gerum
2006-08-21  7:52     ` Jim Cromie
2006-08-21 12:35       ` Gilles Chanteperdrix
2006-08-21 17:31         ` Jim Cromie [this message]
2006-08-21 20:59           ` Gilles Chanteperdrix

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=44E9EE06.8010303@domain.hid \
    --to=jim.cromie@domain.hid \
    --cc=gilles.chanteperdrix@xenomai.org \
    --cc=xenomai@xenomai.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.