blob: 14780051325451f286b91d1adc8cf8bbe73ec485 (
plain)
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
|
#include <list>
#include "common/DecayCounter.h"
#include "global/global_context.h"
using namespace std;
struct RealCounter {
public:
list<int> hits;
void hit(int ms) {
hits.push_back(ms);
}
int get(double hl, int now) {
trim(now-hl);
return hits.size();
}
void trim(int to) {
while (!hits.empty() &&
hits.front() < to)
hits.pop_front();
}
};
int main(int argc, char **argv)
{
int target;
double hl = atof(argv[1]);
cerr << "halflife " << hl << endl;
DecayCounter dc(hl);
RealCounter rc;
utime_t now = ceph_clock_now(g_ceph_context);
for (int ms=0; ms < 300*1000; ms++) {
if (ms % 30000 == 0) {
target = 1 + (rand() % 10) * 10;
if (ms > 200000) target = 0;
}
if (target &&
(rand() % (1000/target) == 0)) {
dc.hit();
rc.hit(ms);
}
if (ms % 500 == 0) dc.get(now);
if (ms % 100 == 0) {
//dc.get(now);
DecayCounter o = dc;
cout << ms << "\t"
<< target*hl << "\t"
<< rc.get(hl*1000, ms) << "\t"
<< o.get(now) << "\t"
<< dc.val << "\t"
// << dc.delta << "\t"
<< o.get_last_vel() << "\t"
<< o.get_last() + o.get_last_vel() << "\t"
<< endl;
}
now += .001;
}
}
|