Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 // 522 522 loop [-1] | 514 // 522 522 loop [-1] |
| 515 // 263 0 bar [-1] | 515 // 263 0 bar [-1] |
| 516 // 263 1 delay [-1] | 516 // 263 1 delay [-1] |
| 517 // 262 262 loop [-1] | 517 // 262 262 loop [-1] |
| 518 // 2 2 (program) [-1] | 518 // 2 2 (program) [-1] |
| 519 // 6 6 (garbage collector) [-1] | 519 // 6 6 (garbage collector) [-1] |
| 520 TEST(CollectCpuProfile) { | 520 TEST(CollectCpuProfile) { |
| 521 LocalContext env; | 521 LocalContext env; |
| 522 v8::HandleScope scope(env->GetIsolate()); | 522 v8::HandleScope scope(env->GetIsolate()); |
| 523 | 523 |
| 524 v8::Script::Compile(v8::String::New(cpu_profiler_test_source))->Run(); | 524 v8::Handle<v8::Script> script = |
|
yurys
2013/06/26 09:34:47
Revert this?
| |
| 525 v8::Script::Compile(v8::String::New(cpu_profiler_test_source)); | |
| 526 script->Run(); | |
| 525 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 527 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| 526 env->Global()->Get(v8::String::New("start"))); | 528 env->Global()->Get(v8::String::New("start"))); |
| 527 | 529 |
| 528 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 530 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
| 529 v8::Local<v8::String> profile_name = v8::String::New("my_profile"); | 531 v8::Local<v8::String> profile_name = v8::String::New("my_profile"); |
| 530 | 532 |
| 531 cpu_profiler->StartCpuProfiling(profile_name); | 533 cpu_profiler->StartCpuProfiling(profile_name); |
| 532 int32_t profiling_interval_ms = 200; | 534 int32_t profiling_interval_ms = 200; |
| 533 #if defined(_WIN32) || defined(_WIN64) | 535 #if defined(_WIN32) || defined(_WIN64) |
| 534 // 200ms is not enough on Windows. See | 536 // 200ms is not enough on Windows. See |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 907 reinterpret_cast<i::CpuProfile*>( | 909 reinterpret_cast<i::CpuProfile*>( |
| 908 const_cast<v8::CpuProfile*>(profile))->Print(); | 910 const_cast<v8::CpuProfile*>(profile))->Print(); |
| 909 | 911 |
| 910 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); | 912 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); |
| 911 GetChild(root, "start"); | 913 GetChild(root, "start"); |
| 912 const v8::CpuProfileNode* startNode = GetChild(root, "start"); | 914 const v8::CpuProfileNode* startNode = GetChild(root, "start"); |
| 913 GetChild(startNode, "fooMethod"); | 915 GetChild(startNode, "fooMethod"); |
| 914 | 916 |
| 915 cpu_profiler->DeleteAllCpuProfiles(); | 917 cpu_profiler->DeleteAllCpuProfiles(); |
| 916 } | 918 } |
| OLD | NEW |