| 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 isolate->GetCpuProfiler()->StartCpuProfiling(v8::String::New("Test")); | 403 isolate->GetCpuProfiler()->StartCpuProfiling(v8::String::New("Test")); |
| 404 isolate->GetCpuProfiler()->StopCpuProfiling(v8::String::New("Test")); | 404 isolate->GetCpuProfiler()->StopCpuProfiling(v8::String::New("Test")); |
| 405 } | 405 } |
| 406 CHECK(i::Isolate::Current()->IsInitialized()); | 406 CHECK(i::Isolate::Current()->IsInitialized()); |
| 407 CHECK_NE(NULL, isolate->GetCpuProfiler()); | 407 CHECK_NE(NULL, isolate->GetCpuProfiler()); |
| 408 isolate->Dispose(); | 408 isolate->Dispose(); |
| 409 CHECK_EQ(NULL, isolate->GetCpuProfiler()); | 409 CHECK_EQ(NULL, isolate->GetCpuProfiler()); |
| 410 } | 410 } |
| 411 | 411 |
| 412 | 412 |
| 413 TEST(ProfileStartEndTime) { | |
| 414 LocalContext env; | |
| 415 v8::HandleScope scope(env->GetIsolate()); | |
| 416 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | |
| 417 | |
| 418 int64_t time_before_profiling = i::OS::Ticks(); | |
| 419 v8::Local<v8::String> profile_name = v8::String::New("test"); | |
| 420 cpu_profiler->StartCpuProfiling(profile_name); | |
| 421 const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name); | |
| 422 CHECK(time_before_profiling <= profile->GetStartTime()); | |
| 423 CHECK(profile->GetStartTime() <= profile->GetEndTime()); | |
| 424 CHECK(profile->GetEndTime() <= i::OS::Ticks()); | |
| 425 } | |
| 426 | |
| 427 | |
| 428 static const v8::CpuProfile* RunProfiler( | 413 static const v8::CpuProfile* RunProfiler( |
| 429 LocalContext& env, v8::Handle<v8::Function> function, | 414 LocalContext& env, v8::Handle<v8::Function> function, |
| 430 v8::Handle<v8::Value> argv[], int argc, | 415 v8::Handle<v8::Value> argv[], int argc, |
| 431 unsigned min_js_samples) { | 416 unsigned min_js_samples) { |
| 432 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 417 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
| 433 v8::Local<v8::String> profile_name = v8::String::New("my_profile"); | 418 v8::Local<v8::String> profile_name = v8::String::New("my_profile"); |
| 434 | 419 |
| 435 cpu_profiler->StartCpuProfiling(profile_name); | 420 cpu_profiler->StartCpuProfiling(profile_name); |
| 436 | 421 |
| 437 i::Sampler* sampler = | 422 i::Sampler* sampler = |
| (...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1317 | 1302 |
| 1318 CHECK_EQ(1, barNode->GetChildrenCount()); | 1303 CHECK_EQ(1, barNode->GetChildrenCount()); |
| 1319 const v8::CpuProfileNode* nativeNode2 = GetChild(barNode, "CallJsFunction2"); | 1304 const v8::CpuProfileNode* nativeNode2 = GetChild(barNode, "CallJsFunction2"); |
| 1320 | 1305 |
| 1321 CHECK_EQ(1, nativeNode2->GetChildrenCount()); | 1306 CHECK_EQ(1, nativeNode2->GetChildrenCount()); |
| 1322 GetChild(nativeNode2, "foo"); | 1307 GetChild(nativeNode2, "foo"); |
| 1323 | 1308 |
| 1324 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 1309 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
| 1325 cpu_profiler->DeleteAllCpuProfiles(); | 1310 cpu_profiler->DeleteAllCpuProfiles(); |
| 1326 } | 1311 } |
| OLD | NEW |