working on fake values

This commit is contained in:
phyto 2019-01-27 13:03:59 +01:00
parent c462c9ad91
commit baec9fdb14
3 changed files with 21 additions and 6 deletions

View File

@ -23,7 +23,7 @@ return v1 ^ v2;
/* --------------------------------------------------------------- */ /* --------------------------------------------------------------- */
int random1000(int type) int random1000(int type)
{ {
int value; int value, foo;
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
fprintf(stderr, ">>> %s(%d)\n", __func__, type); fprintf(stderr, ">>> %s(%d)\n", __func__, type);
@ -36,6 +36,12 @@ switch (type) {
case 1: case 1:
value = (rand()%1000 + rand()%1000) / 2; value = (rand()%1000 + rand()%1000) / 2;
break; break;
case 4:
value = 0;
for (foo=0; foo<4; foo++)
value += rand() % 1000;
value /= 4;
break;
default: default:
value = -1; value = -1;
break; break;

View File

@ -6,21 +6,28 @@ DATAFILE=/tmp/fake-datafile
> ${DATAFILE} > ${DATAFILE}
for s in $(seq 1 2000) for s in $(seq 1 2000)
do do
v=$(./fake-values -s -t 1) v=$(./fake-values -s -t 4)
echo $s $v >> ${DATAFILE} echo $s $v >> ${DATAFILE}
done done
tail -5 ${DATAFILE}
#----- do dome useless computations #----- do dome useless computations
awk ' awk '
NR==1 { debut = $2 } NR==1 {
debut = $2
}
{ {
# print $2-debut, $3 # print $2-debut, $3
v = int($3/25); v = int($3/35);
bucket[v]++; bucket[v]++;
} }
END { END {
for (v=0; v<40; v++) { for (v=0; v<40; v++) {
for (foo=0; foo<bucket[v]; foo++) { printf "%4d ", v;
for (foo=0; foo<bucket[v]/2; foo++) {
printf "-"; printf "-";
} }
print "*" print "*"

View File

@ -1,5 +1,7 @@
/* /*
* fake-values.c * fake-values.c
* -------------
* useless software
*/ */
#include <stdio.h> #include <stdio.h>
@ -30,7 +32,7 @@ if (verbosity > 1) {
fprintf(stderr, "fake values - %s %s\n", __DATE__, __TIME__); 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; return 0;
} }