forked from leverich/mutilate
-
Notifications
You must be signed in to change notification settings - Fork 9
/
TestGenerator.cc
93 lines (72 loc) · 2.38 KB
/
TestGenerator.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include "Generator.h"
#include "util.h"
int main(int argc, char **argv) {
// double now = get_time();
// uint64_t x = fnv_64_buf(&now, sizeof(now));
srand48(0xdeadbeef);
/*
Generator *n = createGenerator("n:1,1"); // new Normal(1, 1);
Generator *e = createGenerator("e:1"); // new Exponential(1);
Generator *p = createGenerator("p:214.476,0.348238"); // new GPareto(214.476, 0.348238);
Generator *g = createGenerator("g:30.7984,8.20449,0.078688"); // new GEV(30.7984, 8.20449, 0.078688);
printf("%f\n", n->generate());
printf("%f\n", e->generate());
printf("%f\n", p->generate());
printf("%f\n", g->generate());
srand48(0);
printf("\n\n");
Discrete *d = new Discrete(createGenerator("p:214.476,0.348238"));
// d->add(.5, -1.0);
//Generator *d = createGenerator("p:214.476,0.348238");
for (int i = 0; i < 20; i++) {
printf("d %d\n", (int) d->generate());
}
printf("\n\n");
srand48(0);
//Discrete *d2 = new Discrete(createGenerator("p:214.476,0.348238"));
// d->add(.5, -1.0);
Generator *d2 = createGenerator("p:214.476,0.348238");
for (int i = 0; i < 20; i++) {
printf("d %d\n", (int) d2->generate());
}
KeyGenerator kg(g);
*/
Generator *g = createFacebookValue();
// Generator *g = createGenerator("pareto:15,214.476,0.348238");
for (int i = 0; i < 1000000; i++)
printf("%f\n", g->generate());
/*
Generator *p2 = createGenerator("p:214.476,0.348238");
// for (int i = 0; i < 1000; i++)
// printf("%f\n", p2->generate());
p2->set_lambda(1000);
for (int i = 0; i < 1000; i++)
printf("%f\n", p2->generate());
*/
// for (int i = 0; i < 10000; i++)
// printf("%s\n", kg.generate(i).c_str());
/*
for (uint64_t ind = 0; ind < 10000; ind++) {
// uint64_t ind = 0;
uint64_t h = fnv_64(ind);
double U = (double) h / ULLONG_MAX;
// double E = e->generate(U); // -log(U);
double G = g->generate(U);
int keylen = MAX(round(G), floor(log10(10000)) + 1);
// printf("ind=%" PRIu64 "\n", ind);
// printf("h=%" PRIu64 "\n", h);
// printf("U=%f\n", U);
// printf("G=%f\n", G);
// printf("keylen=%d\n", keylen);
printf("%7" PRIu64 " %7d key=%0*" PRIu64 "\n", ind, keylen, keylen, ind);
}
*/
}