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

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

Issue 59373003: AllocationProfiler: introduce allocation_profiler flag in V8 api. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 2044 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 CHECK_EQ(0, untracked_objects); 2055 CHECK_EQ(0, untracked_objects);
2056 } 2056 }
2057 2057
2058 2058
2059 static HeapProfilerExtension kHeapProfilerExtension; 2059 static HeapProfilerExtension kHeapProfilerExtension;
2060 v8::DeclareExtension kHeapProfilerExtensionDeclaration( 2060 v8::DeclareExtension kHeapProfilerExtensionDeclaration(
2061 &kHeapProfilerExtension); 2061 &kHeapProfilerExtension);
2062 2062
2063 2063
2064 // This is an example of using checking of JS allocations tracking in a test. 2064 // This is an example of using checking of JS allocations tracking in a test.
2065 TEST(AllocationProfilerString) {
2066 v8::internal::Isolate::Current()->enable_allocation_profiler();
2067 const char* extensions[] = { HeapProfilerExtension::kName };
2068 v8::ExtensionConfiguration config(1, extensions);
2069 LocalContext env(&config);
2070 v8::HandleScope scope(env->GetIsolate());
2071 HeapObjectsTracker tracker;
2072 CompileRun("var a = new String(" ");findUntrackedObjects();");
2073 }
2074
2075
2076 // This is an example of using checking of JS allocations tracking in a test.
2065 TEST(HeapObjectsTracker) { 2077 TEST(HeapObjectsTracker) {
2066 const char* extensions[] = { HeapProfilerExtension::kName }; 2078 const char* extensions[] = { HeapProfilerExtension::kName };
2067 v8::ExtensionConfiguration config(1, extensions); 2079 v8::ExtensionConfiguration config(1, extensions);
2068 LocalContext env(&config); 2080 LocalContext env(&config);
2069 v8::HandleScope scope(env->GetIsolate()); 2081 v8::HandleScope scope(env->GetIsolate());
2070 HeapObjectsTracker tracker; 2082 HeapObjectsTracker tracker;
2071 CompileRun("var a = 1.2"); 2083 CompileRun("var a = 1.2");
2072 CompileRun("var a = 1.2; var b = 1.0; var c = 1.0;"); 2084 CompileRun("var a = 1.2; var b = 1.0; var c = 1.0;");
2073 CompileRun( 2085 CompileRun(
2074 "var a = [];\n" 2086 "var a = [];\n"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2170 2182
2171 const char* names[] = 2183 const char* names[] =
2172 { "(anonymous function)", "start", "f_0_0", "f_0_1", "f_0_2" }; 2184 { "(anonymous function)", "start", "f_0_0", "f_0_1", "f_0_2" };
2173 AllocationTraceNode* node = 2185 AllocationTraceNode* node =
2174 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); 2186 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names)));
2175 CHECK_NE(NULL, node); 2187 CHECK_NE(NULL, node);
2176 CHECK_GE(node->allocation_count(), 100); 2188 CHECK_GE(node->allocation_count(), 100);
2177 CHECK_GE(node->allocation_size(), 4 * node->allocation_count()); 2189 CHECK_GE(node->allocation_size(), 4 * node->allocation_count());
2178 heap_profiler->StopRecordingHeapAllocations(); 2190 heap_profiler->StopRecordingHeapAllocations();
2179 } 2191 }
OLDNEW
« src/x64/macro-assembler-x64.cc ('K') | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698