-
Notifications
You must be signed in to change notification settings - Fork 82
/
rtcycles.hh
61 lines (50 loc) · 1.45 KB
/
rtcycles.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
#ifndef RTCYCLES_HH
#define RTCYCLES_HH
#include <click/batchelement.hh>
/*
* =c
* RoundTripCycleCount()
*
* =s counters
* measures round trip cycles on a push or pull path
*
* =d
*
* Measures the number of CPU cycles it takes for a push or pull to come back
* to the element. This is a good indication of how much CPU is spent on the
* Click path after or before this element.
*
* =h packets read-only
* Returns the number of packets that have passed.
*
* =h cycles read-only
* Returns the accumulated round-trip cycles for all passing packets.
*
* =h reset_counts write-only
* Resets C<packets> and C<cycles> counters to zero when written.
*
* =a SetCycleCount, CycleCountAccum, SetPerfCount, PerfCountAccum
*/
class RTCycles : public BatchElement { public:
RTCycles() CLICK_COLD;
~RTCycles() CLICK_COLD;
const char *class_name() const override { return "RoundTripCycleCount"; }
const char *port_count() const override { return PORTS_1_1; }
void push(int, Packet *p);
Packet *pull(int);
#if HAVE_BATCH
void push_batch(int, PacketBatch *b) override;
PacketBatch *pull_batch(int,unsigned) override;
#endif
void add_handlers() CLICK_COLD;
struct state {
state() : accum(0), npackets(0) {
}
click_cycles_t accum;
click_cycles_t npackets;
};
per_thread<state> _state;
static String read_handler(Element *, void *) CLICK_COLD;
static int reset_handler(const String &, Element*, void*, ErrorHandler*);
};
#endif