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

Unified Diff: test/cctest/test-cpu-profiler.cc

Issue 259803002: Add timestamps to CPU profile samples. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix race Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/sampler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-cpu-profiler.cc
diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc
index d3fcf7d7edee3ea842834152a547c9618bdab92e..6cff7424b7bf7bb8fcd79e4400da66baec0861c7 100644
--- a/test/cctest/test-cpu-profiler.cc
+++ b/test/cctest/test-cpu-profiler.cc
@@ -401,12 +401,12 @@ TEST(ProfileStartEndTime) {
static v8::CpuProfile* RunProfiler(
v8::Handle<v8::Context> env, v8::Handle<v8::Function> function,
v8::Handle<v8::Value> argv[], int argc,
- unsigned min_js_samples) {
+ unsigned min_js_samples, bool collect_samples = false) {
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
v8::Local<v8::String> profile_name =
v8::String::NewFromUtf8(env->GetIsolate(), "my_profile");
- cpu_profiler->StartProfiling(profile_name);
+ cpu_profiler->StartProfiling(profile_name, collect_samples);
i::Sampler* sampler =
reinterpret_cast<i::Isolate*>(env->GetIsolate())->logger()->sampler();
@@ -587,6 +587,37 @@ TEST(CollectCpuProfile) {
}
+TEST(CollectCpuProfileSamples) {
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
+ cpu_profiler_test_source))->Run();
+ v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
+
+ int32_t profiling_interval_ms = 200;
+ v8::Handle<v8::Value> args[] = {
+ v8::Integer::New(env->GetIsolate(), profiling_interval_ms)
+ };
+ v8::CpuProfile* profile =
+ RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200, true);
+
+ CHECK_LE(200, profile->GetSamplesCount());
+ uint64_t end_time = profile->GetEndTime();
+ uint64_t current_time = profile->GetStartTime();
+ CHECK_LE(current_time, end_time);
+ for (int i = 0; i < profile->GetSamplesCount(); i++) {
+ CHECK_NE(NULL, profile->GetSample(i));
+ uint64_t timestamp = profile->GetSampleTimestamp(i);
+ CHECK_LE(current_time, timestamp);
+ CHECK_LE(timestamp, end_time);
+ current_time = timestamp;
+ }
+
+ profile->Delete();
+}
+
static const char* cpu_profiler_test_source2 = "function loop() {}\n"
"function delay() { loop(); }\n"
« no previous file with comments | « src/sampler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698