| 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 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 | 869 |
| 870 if (env.IsEmpty()) { | 870 if (env.IsEmpty()) { |
| 871 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 871 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 872 const char* extensions[] = { "v8/profiler" }; | 872 const char* extensions[] = { "v8/profiler" }; |
| 873 v8::ExtensionConfiguration config(1, extensions); | 873 v8::ExtensionConfiguration config(1, extensions); |
| 874 env = v8::Context::New(&config); | 874 env = v8::Context::New(&config); |
| 875 } | 875 } |
| 876 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 876 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 877 env->Enter(); | 877 env->Enter(); |
| 878 | 878 |
| 879 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); | 879 CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler(); |
| 880 CHECK_EQ(0, profiler->GetProfilesCount()); |
| 880 CompileRun( | 881 CompileRun( |
| 881 "function c() { startProfiling(); }\n" | 882 "function c() { startProfiling(); }\n" |
| 882 "function b() { c(); }\n" | 883 "function b() { c(); }\n" |
| 883 "function a() { b(); }\n" | 884 "function a() { b(); }\n" |
| 884 "a();\n" | 885 "a();\n" |
| 885 "stopProfiling();"); | 886 "stopProfiling();"); |
| 886 CHECK_EQ(1, CpuProfiler::GetProfilesCount()); | 887 CHECK_EQ(1, profiler->GetProfilesCount()); |
| 887 CpuProfile* profile = | 888 CpuProfile* profile = profiler->GetProfile(NULL, 0); |
| 888 CpuProfiler::GetProfile(NULL, 0); | |
| 889 const ProfileTree* topDown = profile->top_down(); | 889 const ProfileTree* topDown = profile->top_down(); |
| 890 const ProfileNode* current = topDown->root(); | 890 const ProfileNode* current = topDown->root(); |
| 891 const_cast<ProfileNode*>(current)->Print(0); | 891 const_cast<ProfileNode*>(current)->Print(0); |
| 892 // The tree should look like this: | 892 // The tree should look like this: |
| 893 // (root) | 893 // (root) |
| 894 // (anonymous function) | 894 // (anonymous function) |
| 895 // a | 895 // a |
| 896 // b | 896 // b |
| 897 // c | 897 // c |
| 898 // There can also be: | 898 // There can also be: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 924 i::OS::SNPrintF(title, "%d", i); | 924 i::OS::SNPrintF(title, "%d", i); |
| 925 // UID must be > 0. | 925 // UID must be > 0. |
| 926 CHECK(collection.StartProfiling(title.start(), i + 1, false)); | 926 CHECK(collection.StartProfiling(title.start(), i + 1, false)); |
| 927 titles[i] = title.start(); | 927 titles[i] = title.start(); |
| 928 } | 928 } |
| 929 CHECK(!collection.StartProfiling( | 929 CHECK(!collection.StartProfiling( |
| 930 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false)); | 930 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false)); |
| 931 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) | 931 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) |
| 932 i::DeleteArray(titles[i]); | 932 i::DeleteArray(titles[i]); |
| 933 } | 933 } |
| OLD | NEW |