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

Side by Side Diff: test/cctest/test-cpu-profiler.cc

Issue 6685084: Add support for CPU and heap profiles deletion. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Implemente per-profile deletion Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // 2 //
3 // Tests of profiles generator and utilities. 3 // Tests of profiles generator and utilities.
4 4
5 #ifdef ENABLE_LOGGING_AND_PROFILING 5 #ifdef ENABLE_LOGGING_AND_PROFILING
6 6
7 #include "v8.h" 7 #include "v8.h"
8 #include "cpu-profiler-inl.h" 8 #include "cpu-profiler-inl.h"
9 #include "cctest.h" 9 #include "cctest.h"
10 #include "../include/v8-profiler.h"
10 11
11 namespace i = v8::internal; 12 namespace i = v8::internal;
12 13
13 using i::CodeEntry; 14 using i::CodeEntry;
14 using i::CpuProfile; 15 using i::CpuProfile;
15 using i::CpuProfiler; 16 using i::CpuProfiler;
16 using i::CpuProfilesCollection; 17 using i::CpuProfilesCollection;
17 using i::ProfileGenerator; 18 using i::ProfileGenerator;
18 using i::ProfileNode; 19 using i::ProfileNode;
19 using i::ProfilerEventsProcessor; 20 using i::ProfilerEventsProcessor;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 InitializeVM(); 230 InitializeVM();
230 TestSetup test_setup; 231 TestSetup test_setup;
231 CpuProfiler::Setup(); 232 CpuProfiler::Setup();
232 CpuProfiler::StartProfiling("1"); 233 CpuProfiler::StartProfiling("1");
233 CpuProfiler::StopProfiling("2"); 234 CpuProfiler::StopProfiling("2");
234 CpuProfiler::StartProfiling("1"); 235 CpuProfiler::StartProfiling("1");
235 CpuProfiler::StopProfiling(""); 236 CpuProfiler::StopProfiling("");
236 CpuProfiler::TearDown(); 237 CpuProfiler::TearDown();
237 } 238 }
238 239
240
241 TEST(DeleteAllCpuProfiles) {
242 InitializeVM();
243 TestSetup test_setup;
244 CpuProfiler::Setup();
245 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
246 CpuProfiler::DeleteAllProfiles();
247 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
248
249 CpuProfiler::StartProfiling("1");
250 CpuProfiler::StopProfiling("1");
251 CHECK_EQ(1, CpuProfiler::GetProfilesCount());
252 CpuProfiler::DeleteAllProfiles();
253 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
254 CpuProfiler::StartProfiling("1");
255 CpuProfiler::StartProfiling("2");
256 CpuProfiler::StopProfiling("2");
257 CpuProfiler::StopProfiling("1");
258 CHECK_EQ(2, CpuProfiler::GetProfilesCount());
259 CpuProfiler::DeleteAllProfiles();
260 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
261
262 // Test profiling cancellation by the 'delete' command.
263 CpuProfiler::StartProfiling("1");
264 CpuProfiler::StartProfiling("2");
265 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
266 CpuProfiler::DeleteAllProfiles();
267 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
268
269 CpuProfiler::TearDown();
270 }
271
272
273 TEST(DeleteCpuProfile) {
274 v8::HandleScope scope;
275 LocalContext env;
276
277 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
278 v8::Local<v8::String> name1 = v8::String::New("1");
279 v8::CpuProfiler::StartProfiling(name1);
280 const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1);
281 CHECK_NE(NULL, p1);
282 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
283 unsigned uid1 = p1->GetUid();
284 CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1));
285 p1->Delete();
286 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
287 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
Vitaly Repeshko 2011/03/22 14:30:36 It'd be nice to test this again later to make sure
mnaganov (inactive) 2011/03/22 16:03:09 Added a couple of times more after.
288
289 v8::Local<v8::String> name2 = v8::String::New("2");
290 v8::CpuProfiler::StartProfiling(name2);
291 const v8::CpuProfile* p2 = v8::CpuProfiler::StopProfiling(name2);
292 CHECK_NE(NULL, p2);
293 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
294 unsigned uid2 = p2->GetUid();
295 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
296 CHECK_EQ(p2, v8::CpuProfiler::FindProfile(uid2));
297 v8::Local<v8::String> name3 = v8::String::New("3");
298 v8::CpuProfiler::StartProfiling(name3);
299 const v8::CpuProfile* p3 = v8::CpuProfiler::StopProfiling(name3);
300 CHECK_NE(NULL, p3);
301 CHECK_EQ(2, v8::CpuProfiler::GetProfilesCount());
302 unsigned uid3 = p3->GetUid();
303 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
304 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
305 p2->Delete();
306 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
307 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
Vitaly Repeshko 2011/03/22 14:30:36 Same here.
mnaganov (inactive) 2011/03/22 16:03:09 Done.
308 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
309 p3->Delete();
310 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
311 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3));
312 }
313
314
315 TEST(DeleteCpuProfileDifferentTokens) {
316 v8::HandleScope scope;
317 LocalContext env;
318
319 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
320 v8::Local<v8::String> name1 = v8::String::New("1");
321 v8::CpuProfiler::StartProfiling(name1);
322 const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1);
323 CHECK_NE(NULL, p1);
324 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
325 unsigned uid1 = p1->GetUid();
326 CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1));
327 v8::Local<v8::String> token1 = v8::String::New("token1");
328 const v8::CpuProfile* p1_t1 = v8::CpuProfiler::FindProfile(uid1, token1);
329 CHECK_NE(NULL, p1_t1);
330 CHECK_NE(p1, p1_t1);
331 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
332 p1->Delete();
333 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
334 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
335 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1, token1));
336 p1_t1->Delete();
337 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
338
339 v8::Local<v8::String> name2 = v8::String::New("2");
340 v8::CpuProfiler::StartProfiling(name2);
341 v8::Local<v8::String> token2 = v8::String::New("token2");
342 const v8::CpuProfile* p2_t2 = v8::CpuProfiler::StopProfiling(name2, token2);
343 CHECK_NE(NULL, p2_t2);
344 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
345 unsigned uid2 = p2_t2->GetUid();
346 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
347 const v8::CpuProfile* p2 = v8::CpuProfiler::FindProfile(uid2);
348 CHECK_NE(p2_t2, p2);
349 v8::Local<v8::String> name3 = v8::String::New("3");
350 v8::CpuProfiler::StartProfiling(name3);
351 const v8::CpuProfile* p3 = v8::CpuProfiler::StopProfiling(name3);
352 CHECK_NE(NULL, p3);
353 CHECK_EQ(2, v8::CpuProfiler::GetProfilesCount());
354 unsigned uid3 = p3->GetUid();
355 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
356 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
357 p2_t2->Delete();
358 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
359 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
360 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
361 p2->Delete();
362 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
363 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
364 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
365 p3->Delete();
366 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
367 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3));
368 }
369
239 #endif // ENABLE_LOGGING_AND_PROFILING 370 #endif // ENABLE_LOGGING_AND_PROFILING
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698