-
Notifications
You must be signed in to change notification settings - Fork 82
/
randload.hh
70 lines (57 loc) · 1.3 KB
/
randload.hh
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
#ifndef CLICK_RANDLOAD_HH
#define CLICK_RANDLOAD_HH
#include <click/config.h>
#include <click/glue.hh>
#include <click/vector.hh>
#include <click/batchelement.hh>
#include <random>
CLICK_DECLS
/*
* =c
* RandLoad([MIN, MAX])
*
* =s research
*
* Random artificial CPU load for each packet
*
* =d
*
* For each packet this element will select a random number between MIN and
* MAX, that designates how many PRNG should be done.
* One PRNG is around 8 CPU cycles.
*
* Keyword arguments are:
*
* =over 8
*
* =item MIN
*
* Integer. Minimal number of PRNG to run for each packets. Default is 1.
*
* =item MAX
*
* Integer. Maximal number of PRNG to run for each packets. Default is 100.
*
* =e
* RandLoad(MIN 1, MAX 100).
*
* =a
* FlowRandLoad, WorkPackage
*/
class RandLoad : public BatchElement {
public:
RandLoad() CLICK_COLD;
~RandLoad() CLICK_COLD;
const char *class_name() const override { return "RandLoad"; }
const char *port_count() const override { return "1/1"; }
const char *processing() const override { return PUSH; }
int configure(Vector<String> &, ErrorHandler *) CLICK_COLD;
int initialize(ErrorHandler *errh);
void push_batch(int, PacketBatch *);
private:
int _min;
int _max;
per_thread<std::mt19937> _gens;
};
CLICK_ENDDECLS
#endif