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

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

Issue 199063003: New Compilation API, part 1, try 2 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 CHECK_EQ(line, node->GetLineNumber()); 1488 CHECK_EQ(line, node->GetLineNumber());
1489 CHECK_EQ(column, node->GetColumnNumber()); 1489 CHECK_EQ(column, node->GetColumnNumber());
1490 } 1490 }
1491 1491
1492 1492
1493 TEST(FunctionDetails) { 1493 TEST(FunctionDetails) {
1494 v8::HandleScope scope(CcTest::isolate()); 1494 v8::HandleScope scope(CcTest::isolate());
1495 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); 1495 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
1496 v8::Context::Scope context_scope(env); 1496 v8::Context::Scope context_scope(env);
1497 1497
1498 v8::Handle<v8::Script> script_a = v8::Script::Compile( 1498 v8::Handle<v8::Script> script_a = CompileWithOrigin(
1499 v8::String::NewFromUtf8(
1500 env->GetIsolate(),
1501 " function foo\n() { try { bar(); } catch(e) {} }\n" 1499 " function foo\n() { try { bar(); } catch(e) {} }\n"
1502 " function bar() { startProfiling(); }\n"), 1500 " function bar() { startProfiling(); }\n",
1503 v8::String::NewFromUtf8(env->GetIsolate(), "script_a")); 1501 "script_a");
1504 script_a->Run(); 1502 script_a->Run();
1505 v8::Handle<v8::Script> script_b = v8::Script::Compile( 1503 v8::Handle<v8::Script> script_b = CompileWithOrigin(
1506 v8::String::NewFromUtf8(
1507 env->GetIsolate(),
1508 "\n\n function baz() { try { foo(); } catch(e) {} }\n" 1504 "\n\n function baz() { try { foo(); } catch(e) {} }\n"
1509 "\n\nbaz();\n" 1505 "\n\nbaz();\n"
1510 "stopProfiling();\n"), 1506 "stopProfiling();\n",
1511 v8::String::NewFromUtf8(env->GetIsolate(), "script_b")); 1507 "script_b");
1512 script_b->Run(); 1508 script_b->Run();
1513 const v8::CpuProfile* profile = i::ProfilerExtension::last_profile; 1509 const v8::CpuProfile* profile = i::ProfilerExtension::last_profile;
1514 const v8::CpuProfileNode* current = profile->GetTopDownRoot(); 1510 const v8::CpuProfileNode* current = profile->GetTopDownRoot();
1515 reinterpret_cast<ProfileNode*>( 1511 reinterpret_cast<ProfileNode*>(
1516 const_cast<v8::CpuProfileNode*>(current))->Print(0); 1512 const_cast<v8::CpuProfileNode*>(current))->Print(0);
1517 // The tree should look like this: 1513 // The tree should look like this:
1518 // 0 (root) 0 #1 1514 // 0 (root) 0 #1
1519 // 0 (anonymous function) 19 #2 no reason script_b:1 1515 // 0 (anonymous function) 19 #2 no reason script_b:1
1520 // 0 baz 19 #3 TryCatchStatement script_b:3 1516 // 0 baz 19 #3 TryCatchStatement script_b:3
1521 // 0 foo 18 #4 TryCatchStatement script_a:2 1517 // 0 foo 18 #4 TryCatchStatement script_a:2
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 inner_profile = NULL; 1559 inner_profile = NULL;
1564 CHECK_EQ(0, iprofiler->GetProfilesCount()); 1560 CHECK_EQ(0, iprofiler->GetProfilesCount());
1565 1561
1566 const v8::CpuProfile* outer_profile = profiler->StopCpuProfiling(outer); 1562 const v8::CpuProfile* outer_profile = profiler->StopCpuProfiling(outer);
1567 CHECK(outer_profile); 1563 CHECK(outer_profile);
1568 CHECK_EQ(1, iprofiler->GetProfilesCount()); 1564 CHECK_EQ(1, iprofiler->GetProfilesCount());
1569 const_cast<v8::CpuProfile*>(outer_profile)->Delete(); 1565 const_cast<v8::CpuProfile*>(outer_profile)->Delete();
1570 outer_profile = NULL; 1566 outer_profile = NULL;
1571 CHECK_EQ(0, iprofiler->GetProfilesCount()); 1567 CHECK_EQ(0, iprofiler->GetProfilesCount());
1572 } 1568 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698