Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: test/unittests/heap/gc-tracer-unittest.cc

Issue 2310143002: [heap] Introduce enum of garbage collection reasons. (Closed)
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/test-weaksets.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <cmath> 5 #include <cmath>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/globals.h" 8 #include "src/globals.h"
9 #include "src/heap/gc-tracer.h" 9 #include "src/heap/gc-tracer.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 EXPECT_EQ((counter3 - counter1) / (time3 - time1), throughput); 153 EXPECT_EQ((counter3 - counter1) / (time3 - time1), throughput);
154 } 154 }
155 155
156 TEST_F(GCTracerTest, RegularScope) { 156 TEST_F(GCTracerTest, RegularScope) {
157 GCTracer* tracer = i_isolate()->heap()->tracer(); 157 GCTracer* tracer = i_isolate()->heap()->tracer();
158 tracer->ResetForTesting(); 158 tracer->ResetForTesting();
159 159
160 EXPECT_DOUBLE_EQ(0.0, tracer->current_.scopes[GCTracer::Scope::MC_MARK]); 160 EXPECT_DOUBLE_EQ(0.0, tracer->current_.scopes[GCTracer::Scope::MC_MARK]);
161 // Sample not added because it's not within a started tracer. 161 // Sample not added because it's not within a started tracer.
162 tracer->AddScopeSample(GCTracer::Scope::MC_MARK, 100); 162 tracer->AddScopeSample(GCTracer::Scope::MC_MARK, 100);
163 tracer->Start(MARK_COMPACTOR, "gc unittest", "collector unittest"); 163 tracer->Start(MARK_COMPACTOR, GarbageCollectionReason::kTesting,
164 "collector unittest");
164 tracer->AddScopeSample(GCTracer::Scope::MC_MARK, 100); 165 tracer->AddScopeSample(GCTracer::Scope::MC_MARK, 100);
165 tracer->Stop(MARK_COMPACTOR); 166 tracer->Stop(MARK_COMPACTOR);
166 EXPECT_DOUBLE_EQ(100.0, tracer->current_.scopes[GCTracer::Scope::MC_MARK]); 167 EXPECT_DOUBLE_EQ(100.0, tracer->current_.scopes[GCTracer::Scope::MC_MARK]);
167 } 168 }
168 169
169 TEST_F(GCTracerTest, IncrementalScope) { 170 TEST_F(GCTracerTest, IncrementalScope) {
170 GCTracer* tracer = i_isolate()->heap()->tracer(); 171 GCTracer* tracer = i_isolate()->heap()->tracer();
171 tracer->ResetForTesting(); 172 tracer->ResetForTesting();
172 173
173 EXPECT_DOUBLE_EQ( 174 EXPECT_DOUBLE_EQ(
174 0.0, tracer->current_.scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE]); 175 0.0, tracer->current_.scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE]);
175 // Sample is added because its ScopeId is listed as incremental sample. 176 // Sample is added because its ScopeId is listed as incremental sample.
176 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 100); 177 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 100);
177 tracer->Start(MARK_COMPACTOR, "gc unittest", "collector unittest"); 178 tracer->Start(MARK_COMPACTOR, GarbageCollectionReason::kTesting,
179 "collector unittest");
178 // Switch to incremental MC to enable writing back incremental scopes. 180 // Switch to incremental MC to enable writing back incremental scopes.
179 tracer->current_.type = GCTracer::Event::INCREMENTAL_MARK_COMPACTOR; 181 tracer->current_.type = GCTracer::Event::INCREMENTAL_MARK_COMPACTOR;
180 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 100); 182 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 100);
181 tracer->Stop(MARK_COMPACTOR); 183 tracer->Stop(MARK_COMPACTOR);
182 EXPECT_DOUBLE_EQ( 184 EXPECT_DOUBLE_EQ(
183 200.0, tracer->current_.scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE]); 185 200.0, tracer->current_.scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE]);
184 } 186 }
185 187
186 TEST_F(GCTracerTest, IncrementalMarkingDetails) { 188 TEST_F(GCTracerTest, IncrementalMarkingDetails) {
187 GCTracer* tracer = i_isolate()->heap()->tracer(); 189 GCTracer* tracer = i_isolate()->heap()->tracer();
188 tracer->ResetForTesting(); 190 tracer->ResetForTesting();
189 191
190 // Round 1. 192 // Round 1.
191 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 50); 193 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 50);
192 tracer->Start(MARK_COMPACTOR, "gc unittest", "collector unittest"); 194 tracer->Start(MARK_COMPACTOR, GarbageCollectionReason::kTesting,
195 "collector unittest");
193 // Switch to incremental MC to enable writing back incremental scopes. 196 // Switch to incremental MC to enable writing back incremental scopes.
194 tracer->current_.type = GCTracer::Event::INCREMENTAL_MARK_COMPACTOR; 197 tracer->current_.type = GCTracer::Event::INCREMENTAL_MARK_COMPACTOR;
195 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 100); 198 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 100);
196 tracer->Stop(MARK_COMPACTOR); 199 tracer->Stop(MARK_COMPACTOR);
197 EXPECT_DOUBLE_EQ( 200 EXPECT_DOUBLE_EQ(
198 100, 201 100,
199 tracer->current_ 202 tracer->current_
200 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE] 203 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE]
201 .longest_step); 204 .longest_step);
202 EXPECT_EQ( 205 EXPECT_EQ(
203 2, 206 2,
204 tracer->current_ 207 tracer->current_
205 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE] 208 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE]
206 .steps); 209 .steps);
207 EXPECT_DOUBLE_EQ( 210 EXPECT_DOUBLE_EQ(
208 150, 211 150,
209 tracer->current_ 212 tracer->current_
210 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE] 213 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE]
211 .cumulative_duration); 214 .cumulative_duration);
212 215
213 // Round 2. Cumulative numbers should add up, others should be reset. 216 // Round 2. Cumulative numbers should add up, others should be reset.
214 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 13); 217 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 13);
215 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 15); 218 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 15);
216 tracer->Start(MARK_COMPACTOR, "gc unittest", "collector unittest"); 219 tracer->Start(MARK_COMPACTOR, GarbageCollectionReason::kTesting,
220 "collector unittest");
217 // Switch to incremental MC to enable writing back incremental scopes. 221 // Switch to incremental MC to enable writing back incremental scopes.
218 tracer->current_.type = GCTracer::Event::INCREMENTAL_MARK_COMPACTOR; 222 tracer->current_.type = GCTracer::Event::INCREMENTAL_MARK_COMPACTOR;
219 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 122); 223 tracer->AddScopeSample(GCTracer::Scope::MC_INCREMENTAL_FINALIZE, 122);
220 tracer->Stop(MARK_COMPACTOR); 224 tracer->Stop(MARK_COMPACTOR);
221 EXPECT_DOUBLE_EQ( 225 EXPECT_DOUBLE_EQ(
222 122, 226 122,
223 tracer->current_ 227 tracer->current_
224 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE] 228 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE]
225 .longest_step); 229 .longest_step);
226 EXPECT_EQ( 230 EXPECT_EQ(
227 3, 231 3,
228 tracer->current_ 232 tracer->current_
229 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE] 233 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE]
230 .steps); 234 .steps);
231 EXPECT_DOUBLE_EQ( 235 EXPECT_DOUBLE_EQ(
232 300, 236 300,
233 tracer->current_ 237 tracer->current_
234 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE] 238 .incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE]
235 .cumulative_duration); 239 .cumulative_duration);
236 } 240 }
237 241
238 } // namespace internal 242 } // namespace internal
239 } // namespace v8 243 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/test-weaksets.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698