1 /* src/vm/cycles-stats.h - macros for cycle count statistics
3 Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
27 Authors: Edwin Steiner
35 #ifndef _CYCLES_STATS_H
36 #define _CYCLES_STATS_H
41 #if defined(ENABLE_CYCLES_STATS)
43 #define CYCLES_STATS_DECLARE(name,nbins,divisor) \
44 static const int CYCLES_STATS_##name##_MAX = (nbins); \
45 static const int CYCLES_STATS_##name##_DIV = (divisor); \
46 static u4 cycles_stats_##name##_bins[(nbins) + 1] = { 0 }; \
47 static u4 cycles_stats_##name##_count = 0; \
48 static u8 cycles_stats_##name##_max = 0; \
49 static u8 cycles_stats_##name##_min = 1000000000;
51 #define CYCLES_STATS_GET(var) \
52 (var) = asm_get_cycle_count() \
54 #define CYCLES_STATS_COUNT(name,cyclesexpr) \
56 u8 cyc = (cyclesexpr); \
57 if (cyc > cycles_stats_##name##_max) \
58 cycles_stats_##name##_max = cyc; \
59 if (cyc < cycles_stats_##name##_min) \
60 cycles_stats_##name##_min = cyc; \
61 cyc /= CYCLES_STATS_##name##_DIV; \
62 if (cyc < CYCLES_STATS_##name##_MAX) \
63 cycles_stats_##name##_bins[cyc]++; \
65 cycles_stats_##name##_bins[CYCLES_STATS_##name##_MAX]++; \
66 cycles_stats_##name##_count++; \
69 #define CYCLES_STATS_PRINT(name,file) \
72 fprintf(file,"\t%s: %u calls\n", \
73 #name, cycles_stats_##name##_count); \
74 fprintf(file,"\t%s cycles distribution:\n", #name); \
75 fprintf(file,"\t\tmin = %llu\n", \
76 (unsigned long long)cycles_stats_##name##_min); \
77 for (local_i=0; local_i<CYCLES_STATS_##name##_MAX; ++local_i) { \
78 fprintf(file,"\t\t< %5d: %u\n", \
79 (local_i+1) * CYCLES_STATS_##name##_DIV, \
80 cycles_stats_##name##_bins[local_i]); \
82 fprintf(file,"\t\t>= %5d: %u\n", \
83 CYCLES_STATS_##name##_MAX * CYCLES_STATS_##name##_DIV, \
84 cycles_stats_##name##_bins[local_i]); \
85 fprintf(file,"\t\tmax = %llu\n", \
86 (unsigned long long)cycles_stats_##name##_max); \
90 #else /* !defined(ENABLE_CYCLES_STATS) */
92 #define CYCLES_STATS_DECLARE(name,nbins,divisor)
93 #define CYCLES_STATS_GET(var)
94 #define CYCLES_STATS_COUNT(name,cyclesexpr)
95 #define CYCLES_STATS_PRINT(name,file)
97 #endif /* defined(ENABLE_CYCLES_STATS) */
99 #endif /* _CYCLES_STATS_H */
102 * These are local overrides for various environment variables in Emacs.
103 * Please do not remove this and leave it at the end of the file, where
104 * Emacs will automagically detect them.
105 * ---------------------------------------------------------------------
108 * indent-tabs-mode: t
112 * vim:noexpandtab:sw=4:ts=4: