Browse Source

working on fake values

phyto 1 year ago
parent
commit
baec9fdb14
3 changed files with 21 additions and 6 deletions
  1. 7
    1
      core/utils.c
  2. 11
    4
      exemple.sh
  3. 3
    1
      fake-values.c

+ 7
- 1
core/utils.c View File

@@ -23,7 +23,7 @@ return v1 ^ v2;
23 23
 /* --------------------------------------------------------------- */
24 24
 int random1000(int type)
25 25
 {
26
-int         value;
26
+int         value, foo;
27 27
 
28 28
 #if DEBUG_LEVEL > 1
29 29
 fprintf(stderr, ">>> %s(%d)\n", __func__, type);
@@ -36,6 +36,12 @@ switch (type) {
36 36
 	case 1:
37 37
 		value = (rand()%1000 + rand()%1000) / 2;
38 38
 		break;
39
+	case 4:
40
+		value = 0;
41
+		for (foo=0; foo<4; foo++)
42
+			value += rand() % 1000;
43
+		value /= 4;
44
+		break;
39 45
 	default:
40 46
 		value = -1;
41 47
 		break;

+ 11
- 4
exemple.sh View File

@@ -6,21 +6,28 @@ DATAFILE=/tmp/fake-datafile
6 6
 > ${DATAFILE}
7 7
 for s in $(seq 1 2000)
8 8
 do
9
-    v=$(./fake-values -s -t 1)
9
+    v=$(./fake-values -s -t 4)
10 10
     echo $s $v >> ${DATAFILE}
11 11
 done
12 12
 
13
+tail -5 ${DATAFILE}
14
+
13 15
 #-----  do dome useless computations
14 16
 awk	'
15
-	NR==1	{ debut = $2 }
17
+	NR==1	{
18
+		debut = $2
19
+		}
20
+		
16 21
 		{
17 22
 		# print $2-debut, $3
18
-		v = int($3/25);
23
+		v = int($3/35);
19 24
 		bucket[v]++;
20 25
 		}
26
+		
21 27
 	END	{
22 28
 		for (v=0; v<40; v++) {
23
-			for (foo=0; foo<bucket[v]; foo++) {
29
+			printf "%4d ", v;
30
+			for (foo=0; foo<bucket[v]/2; foo++) {
24 31
 				printf "-";
25 32
 				}
26 33
 			print "*"

+ 3
- 1
fake-values.c View File

@@ -1,5 +1,7 @@
1 1
 /*
2 2
  *		fake-values.c
3
+ *		-------------
4
+ *		useless software
3 5
  */
4 6
 
5 7
 #include  <stdio.h>
@@ -30,7 +32,7 @@ if (verbosity > 1) {
30 32
 	fprintf(stderr, "fake values - %s %s\n", __DATE__, __TIME__);
31 33
 	}
32 34
 
33
-printf("%f %d\n", dtime(), random1000(type));
35
+printf("%.3f %d\n", dtime(), random1000(type));
34 36
 
35 37
 return 0;
36 38
 }

Loading…
Cancel
Save