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

Side by Side Diff: test/cctest/test-profile-generator.cc

Issue 17642009: CPUProfiler: propagate scriptId to the front-end (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: completely reworked Created 7 years, 5 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 | « src/profile-generator-inl.h ('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 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 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 i::OS::SNPrintF(title, "%d", i); 898 i::OS::SNPrintF(title, "%d", i);
899 // UID must be > 0. 899 // UID must be > 0.
900 CHECK(collection.StartProfiling(title.start(), i + 1, false)); 900 CHECK(collection.StartProfiling(title.start(), i + 1, false));
901 titles[i] = title.start(); 901 titles[i] = title.start();
902 } 902 }
903 CHECK(!collection.StartProfiling( 903 CHECK(!collection.StartProfiling(
904 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false)); 904 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false));
905 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) 905 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i)
906 i::DeleteArray(titles[i]); 906 i::DeleteArray(titles[i]);
907 } 907 }
908
909
910 TEST(ProfileNodeScriptId) {
911 // This test does not pass with inlining enabled since inlined functions
912 // don't appear in the stack trace.
yurys 2013/07/01 14:50:00 I think we should be testing with inlining on as w
913 i::FLAG_use_inlining = false;
914
915 v8::Isolate* isolate = v8::Isolate::GetCurrent();
916 v8::HandleScope scope(isolate);
917 const char* extensions[] = { "v8/profiler" };
918 v8::ExtensionConfiguration config(1, extensions);
919 v8::Local<v8::Context> context = v8::Context::New(isolate, &config);
920 context->Enter();
yurys 2013/07/01 14:50:00 Please use LocalContext env(config); instead, it w
921
922 CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler();
923 CHECK_EQ(0, profiler->GetProfilesCount());
924 v8::Handle<v8::Script> script_a = v8::Script::Compile(v8::String::New(
925 "function a() { startProfiling(); }\n"));
926 script_a->Run();
927 v8::Handle<v8::Script> script_b = v8::Script::Compile(v8::String::New(
928 "function b() { a(); }\n"
929 "b();\n"
930 "stopProfiling();\n"));
931 script_b->Run();
932 CHECK_EQ(1, profiler->GetProfilesCount());
933 CpuProfile* profile = profiler->GetProfile(NULL, 0);
yurys 2013/07/01 14:50:00 Why don't we use public API here?
934 const ProfileTree* topDown = profile->top_down();
935 const ProfileNode* current = topDown->root();
936 const_cast<ProfileNode*>(current)->Print(0);
937 // The tree should look like this:
938 // (root)
939 // (anonymous function)
940 // b
941 // a
942 // There can also be:
943 // startProfiling
944 // if the sampler managed to get a tick.
945 current = PickChild(current, "(anonymous function)");
yurys 2013/07/01 14:50:00 Please use i::ProfilerGenerator::kAnonymousFunctio
946 CHECK_NE(NULL, const_cast<ProfileNode*>(current));
947
948 current = PickChild(current, "b");
949 CHECK_NE(NULL, const_cast<ProfileNode*>(current));
950 CHECK_EQ(script_b->GetId(), current->entry()->script_id());
951
952 current = PickChild(current, "a");
953 CHECK_NE(NULL, const_cast<ProfileNode*>(current));
954 CHECK_EQ(script_a->GetId(), current->entry()->script_id());
955 }
956
957
OLDNEW
« no previous file with comments | « src/profile-generator-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698