Browse Source

working on fakevalues generator

tth 2 years ago
parent
commit
639adde484
2 changed files with 25 additions and 2 deletions
  1. 14
    2
      exemple.sh
  2. 11
    0
      funcs.c

+ 14
- 2
exemple.sh View File

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

+ 11
- 0
funcs.c View File

@@ -3,14 +3,25 @@
3 3
  */
4 4
 
5 5
 #include  <stdio.h>
6
+#include <unistd.h>
6 7
 #include  <stdlib.h>
7 8
 #include  <string.h>
9
+#include  <time.h>
8 10
 #include  <sys/time.h>
9 11
 
10 12
 #include  "funcs.h"
11 13
 
12 14
 extern int verbosity;
13 15
 
16
+/* --------------------------------------------------------------- */
17
+int seed_my_rand(int foo)
18
+{
19
+long	v1, v2;
20
+
21
+v1 = getpid();		v2 = time(NULL);
22
+
23
+return v1 ^ v2;
24
+}
14 25
 /* --------------------------------------------------------------- */
15 26
 
16 27
 int random1000(int type)

Loading…
Cancel
Save