From baec9fdb148830ca3fd419dc4aba1d8f3e1511e5 Mon Sep 17 00:00:00 2001 From: phyto Date: Sun, 27 Jan 2019 13:03:59 +0100 Subject: [PATCH] working on fake values --- core/utils.c | 8 +++++++- exemple.sh | 15 +++++++++++---- fake-values.c | 4 +++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/core/utils.c b/core/utils.c index 17cf615..90049c6 100644 --- a/core/utils.c +++ b/core/utils.c @@ -23,7 +23,7 @@ return v1 ^ v2; /* --------------------------------------------------------------- */ int random1000(int type) { -int value; +int value, foo; #if DEBUG_LEVEL > 1 fprintf(stderr, ">>> %s(%d)\n", __func__, type); @@ -36,6 +36,12 @@ switch (type) { case 1: value = (rand()%1000 + rand()%1000) / 2; break; + case 4: + value = 0; + for (foo=0; foo<4; foo++) + value += rand() % 1000; + value /= 4; + break; default: value = -1; break; diff --git a/exemple.sh b/exemple.sh index 80b52ae..3e1824a 100755 --- a/exemple.sh +++ b/exemple.sh @@ -6,21 +6,28 @@ DATAFILE=/tmp/fake-datafile > ${DATAFILE} for s in $(seq 1 2000) do - v=$(./fake-values -s -t 1) + v=$(./fake-values -s -t 4) echo $s $v >> ${DATAFILE} done +tail -5 ${DATAFILE} + #----- do dome useless computations awk ' - NR==1 { debut = $2 } + NR==1 { + debut = $2 + } + { # print $2-debut, $3 - v = int($3/25); + v = int($3/35); bucket[v]++; } + END { for (v=0; v<40; v++) { - for (foo=0; foo @@ -30,7 +32,7 @@ if (verbosity > 1) { fprintf(stderr, "fake values - %s %s\n", __DATE__, __TIME__); } -printf("%f %d\n", dtime(), random1000(type)); +printf("%.3f %d\n", dtime(), random1000(type)); return 0; }