-
Notifications
You must be signed in to change notification settings - Fork 0
/
profiler.h
66 lines (52 loc) · 1.45 KB
/
profiler.h
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
#ifndef _PROFILER_H_
#define _PROFILER_H_
#include <sys/queue.h>
#include <sys/tree.h>
#ifndef __unused
#define __unused __attribute__((unused))
#endif
/*
just for the jlong definition
*/
#include <jni.h>
struct agent_method {
const char *class_sig;
const char *name;
const char *sig;
jlong call_count;
jlong total_time;
jlong sub_time;
};
enum agent_event_type {
EVENT_ENTRY,
EVENT_NORMAL_EXIT,
EVENT_EXCEPTION_EXIT,
};
struct agent_event {
jlong tid;
jlong nanos;
struct agent_method *method;
enum agent_event_type event_type;
};
struct thread_stack_entry {
SLIST_ENTRY(thread_stack_entry) slist;
struct agent_method *method;
jlong entry_nanos;
};
struct thread_stack {
RB_ENTRY(thread_stack) rb;
jlong tid;
SLIST_HEAD(thread_stack_head, thread_stack_entry) head;
};
struct profiler {
RB_HEAD(threads_rb, thread_stack) threads;
};
struct agent_method_iterator;
const struct agent_method *agent_method_iterator_next(struct agent_method_iterator *iterator);
void *profiler_allocate(struct profiler *profiler, jlong size);
void profiler_deallocate(struct profiler *profiler, void *mem);
void profiler_start(struct profiler *profiler);
void profiler_init_method(struct profiler *profiler, struct agent_method *method);
void profiler_process_event(struct profiler *profiler, struct agent_event *event);
void profiler_stop(struct profiler *profiler, struct agent_method_iterator *iterator);
#endif