blob: 4107dd3e484f4e21cf8e2f5a82b8039b6bac39a5 [file] [log] [blame]
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00001// Copyright 2012 the V8 project authors. All rights reserved.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +00002// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#include "v8.h"
29
30#include "v8-counters.h"
31
kasperl@chromium.org71affb52009-05-26 05:44:31 +000032namespace v8 {
33namespace internal {
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000034
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +000035Counters::Counters() {
ager@chromium.orgbb29dc92009-03-24 13:25:23 +000036#define HT(name, caption) \
jkummerow@chromium.org28583c92012-07-16 11:31:55 +000037 HistogramTimer name = { {#caption, 0, 10000, 50, NULL, false}, 0, 0 }; \
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +000038 name##_ = name;
39 HISTOGRAM_TIMER_LIST(HT)
40#undef HT
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000041
jkummerow@chromium.org28583c92012-07-16 11:31:55 +000042#define HP(name, caption) \
43 Histogram name = { #caption, 0, 101, 100, NULL, false }; \
44 name##_ = name;
45 HISTOGRAM_PERCENTAGE_LIST(HP)
46#undef HP
47
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +000048#define HM(name, caption) \
49 Histogram name = { #caption, 1000, 500000, 50, NULL, false }; \
50 name##_ = name;
51 HISTOGRAM_MEMORY_LIST(HM)
52#undef HM
53
kasperl@chromium.orgb9123622008-09-17 14:05:56 +000054#define SC(name, caption) \
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +000055 StatsCounter name = { "c:" #caption, NULL, false };\
56 name##_ = name;
kasperl@chromium.orgb9123622008-09-17 14:05:56 +000057
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +000058 STATS_COUNTER_LIST_1(SC)
59 STATS_COUNTER_LIST_2(SC)
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000060#undef SC
61
jkummerow@chromium.org28583c92012-07-16 11:31:55 +000062#define SC(name) \
63 StatsCounter count_of_##name = { "c:" "V8.CountOf_" #name, NULL, false };\
64 count_of_##name##_ = count_of_##name; \
65 StatsCounter size_of_##name = { "c:" "V8.SizeOf_" #name, NULL, false };\
66 size_of_##name##_ = size_of_##name;
67 INSTANCE_TYPE_LIST(SC)
68#undef SC
69
verwaest@chromium.org753aee42012-07-17 16:15:42 +000070#define SC(name) \
71 StatsCounter count_of_CODE_TYPE_##name = { \
72 "c:" "V8.CountOf_CODE_TYPE-" #name, NULL, false }; \
73 count_of_CODE_TYPE_##name##_ = count_of_CODE_TYPE_##name; \
74 StatsCounter size_of_CODE_TYPE_##name = { \
75 "c:" "V8.SizeOf_CODE_TYPE-" #name, NULL, false }; \
76 size_of_CODE_TYPE_##name##_ = size_of_CODE_TYPE_##name;
77 CODE_KIND_LIST(SC)
78#undef SC
79
yangguo@chromium.org304cc332012-07-24 07:59:48 +000080#define SC(name) \
81 StatsCounter count_of_FIXED_ARRAY_##name = { \
82 "c:" "V8.CountOf_FIXED_ARRAY-" #name, NULL, false }; \
83 count_of_FIXED_ARRAY_##name##_ = count_of_FIXED_ARRAY_##name; \
84 StatsCounter size_of_FIXED_ARRAY_##name = { \
85 "c:" "V8.SizeOf_FIXED_ARRAY-" #name, NULL, false }; \
86 size_of_FIXED_ARRAY_##name##_ = size_of_FIXED_ARRAY_##name;
87 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(SC)
88#undef SC
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +000089}
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000090
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +000091void Counters::ResetHistograms() {
92#define HT(name, caption) name##_.Reset();
93 HISTOGRAM_TIMER_LIST(HT)
94#undef HT
95
96#define HP(name, caption) name##_.Reset();
97 HISTOGRAM_PERCENTAGE_LIST(HP)
98#undef HP
99
100#define HM(name, caption) name##_.Reset();
101 HISTOGRAM_MEMORY_LIST(HM)
102#undef HM
103}
104
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000105} } // namespace v8::internal