CACAO
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
source
cacao
src
vm
cycles-stats.hpp
Go to the documentation of this file.
1
/* src/vm/cycles-stats.hpp - macros for cycle count statistics
2
3
Copyright (C) 1996-2005, 2006, 2009
4
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6
This file is part of CACAO.
7
8
This program is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public License as
10
published by the Free Software Foundation; either version 2, or (at
11
your option) any later version.
12
13
This program is distributed in the hope that it will be useful, but
14
WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
General Public License for more details.
17
18
You should have received a copy of the GNU General Public License
19
along with this program; if not, write to the Free Software
20
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21
02110-1301, USA.
22
23
*/
24
25
#ifndef CYCLES_STATS_HPP_
26
#define CYCLES_STATS_HPP_
27
28
#include "config.h"
29
#include "
vm/types.hpp
"
30
31
#if defined(ENABLE_CYCLES_STATS)
32
33
#include <stdio.h>
34
35
#include "md.hpp"
36
37
#define CYCLES_STATS_DECLARE(name,nbins,divisor) \
38
static const int CYCLES_STATS_##name##_MAX = (nbins); \
39
static const int CYCLES_STATS_##name##_DIV = (divisor); \
40
static u4 cycles_stats_##name##_bins[(nbins) + 1] = { 0 }; \
41
static u4 cycles_stats_##name##_count = 0; \
42
static u8 cycles_stats_##name##_total = 0; \
43
static u8 cycles_stats_##name##_max = 0; \
44
static u8 cycles_stats_##name##_min = 1000000000;
45
46
#define CYCLES_STATS_GET(var) \
47
(var) = md_get_cycle_count() \
48
49
#define CYCLES_STATS_COUNT(name,cyclesexpr) \
50
do { \
51
u8 cyc = (cyclesexpr); \
52
cycles_stats_##name##_total += cyc; \
53
if (cyc > cycles_stats_##name##_max) \
54
cycles_stats_##name##_max = cyc; \
55
if (cyc < cycles_stats_##name##_min) \
56
cycles_stats_##name##_min = cyc; \
57
cyc /= CYCLES_STATS_##name##_DIV; \
58
if (cyc < CYCLES_STATS_##name##_MAX) \
59
cycles_stats_##name##_bins[cyc]++; \
60
else \
61
cycles_stats_##name##_bins[CYCLES_STATS_##name##_MAX]++; \
62
cycles_stats_##name##_count++; \
63
} while (0)
64
65
#define CYCLES_STATS_COUNT_OVER(name,ovname,cyclesexpr) \
66
do { \
67
u8 cyc = (cyclesexpr); \
68
if (cyc / CYCLES_STATS_##name##_DIV >= CYCLES_STATS_##name##_MAX) \
69
CYCLES_STATS_COUNT(ovname,cyc); \
70
} while (0)
71
72
#define CYCLES_STATS_PRINT(name,file) \
73
do { \
74
cycles_stats_print((file), #name, \
75
CYCLES_STATS_##name##_MAX, CYCLES_STATS_##name##_DIV, \
76
cycles_stats_##name##_bins, cycles_stats_##name##_count, \
77
cycles_stats_##name##_total, \
78
cycles_stats_##name##_min, cycles_stats_##name##_max, 0); \
79
} while (0)
80
81
#define CYCLES_STATS_PRINT_OVERHEAD(name,file) \
82
do { \
83
cycles_stats_print((file), #name, \
84
CYCLES_STATS_##name##_MAX, CYCLES_STATS_##name##_DIV, \
85
cycles_stats_##name##_bins, cycles_stats_##name##_count, \
86
cycles_stats_##name##_total, \
87
cycles_stats_##name##_min, cycles_stats_##name##_max, 1); \
88
} while (0)
89
90
#define CYCLES_STATS_DECLARE_AND_START \
91
u8 cycles_start = md_get_cycle_count(); \
92
u8 cycles_end;
93
94
#define CYCLES_STATS_DECLARE_AND_START_WITH_OVERHEAD \
95
u8 cycles_start = md_get_cycle_count(); \
96
u8 cycles_overhead = md_get_cycle_count(); \
97
u8 cycles_end;
98
99
#define CYCLES_STATS_END(name) \
100
cycles_end = md_get_cycle_count(); \
101
CYCLES_STATS_COUNT(name, cycles_end - cycles_start);
102
103
#define CYCLES_STATS_END_WITH_OVERHEAD(name,ovname) \
104
cycles_end = md_get_cycle_count(); \
105
CYCLES_STATS_COUNT(ovname, cycles_overhead - cycles_start); \
106
CYCLES_STATS_COUNT(name, cycles_end - cycles_overhead);
107
108
void
cycles_stats_print(FILE *file,
109
const
char
*
name
,
int
nbins,
int
div,
110
u4
*bins,
u8
count,
u8
total,
u8
min
,
u8
max
,
111
int
overhead);
112
113
#else
/* !defined(ENABLE_CYCLES_STATS) */
114
115
#define CYCLES_STATS_DECLARE(name,nbins,divisor)
116
#define CYCLES_STATS_GET(var)
117
#define CYCLES_STATS_COUNT(name,cyclesexpr)
118
#define CYCLES_STATS_COUNT_OVER(name,ovname,cyclesexpr)
119
#define CYCLES_STATS_PRINT(name,file)
120
#define CYCLES_STATS_PRINT_OVERHEAD(name,file)
121
#define CYCLES_STATS_DECLARE_AND_START
122
#define CYCLES_STATS_DECLARE_AND_START_WITH_OVERHEAD
123
#define CYCLES_STATS_END(name)
124
#define CYCLES_STATS_END_WITH_OVERHEAD(name,ovname)
125
126
#endif
/* defined(ENABLE_CYCLES_STATS) */
127
128
#endif // CYCLES_STATS_HPP_
129
130
/*
131
* These are local overrides for various environment variables in Emacs.
132
* Please do not remove this and leave it at the end of the file, where
133
* Emacs will automagically detect them.
134
* ---------------------------------------------------------------------
135
* Local variables:
136
* mode: c++
137
* indent-tabs-mode: t
138
* c-basic-offset: 4
139
* tab-width: 4
140
* End:
141
* vim:noexpandtab:sw=4:ts=4:
142
*/
max
#define max(a, b)
Definition:
lsra.hpp:80
types.hpp
name
JNIEnv jclass jobject const char * name
Definition:
jvmti.h:312
min
#define min(a, b)
Definition:
lsra.hpp:79
u8
uint64_t u8
Definition:
types.hpp:49
u4
uint32_t u4
Definition:
types.hpp:46
Generated on Fri Aug 4 2017 03:01:47 for CACAO by
1.8.5