blob: 49af781a55a1001be19f135c4a7e8bf24192f597 (
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
|
#include <mono/metadata/profiler.h>
/*
* Bare bones profiler. Compile with:
* gcc -shared -o mono-profiler-sample.so sample.c `pkg-config --cflags --libs mono`
* Install the binary where the dynamic loader can find it.
* Then run mono with:
* mono --profile=sample your_application.exe
*/
struct _MonoProfiler {
int ncalls;
};
/* called at the end of the program */
static void
sample_shutdown (MonoProfiler *prof)
{
g_print ("total number of calls: %d\n", prof->ncalls);
}
static void
sample_method_enter (MonoProfiler *prof, MonoMethod *method)
{
prof->ncalls++;
}
static void
sample_method_leave (MonoProfiler *prof, MonoMethod *method)
{
}
/* the entry point */
void
mono_profiler_startup (const char *desc)
{
MonoProfiler *prof;
prof = g_new0 (MonoProfiler, 1);
mono_profiler_install (prof, sample_shutdown);
mono_profiler_install_enter_leave (sample_method_enter, sample_method_leave);
mono_profiler_set_events (MONO_PROFILE_ENTER_LEAVE);
}
|