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 double time_before_profiling = i::OS::TimeCurrentMillis(); |
| 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::TimeCurrentMillis()); |
| 425 } |
| 426 |
| 427 |
413 static const v8::CpuProfile* RunProfiler( | 428 static const v8::CpuProfile* RunProfiler( |
414 LocalContext& env, v8::Handle<v8::Function> function, | 429 LocalContext& env, v8::Handle<v8::Function> function, |
415 v8::Handle<v8::Value> argv[], int argc, | 430 v8::Handle<v8::Value> argv[], int argc, |
416 unsigned min_js_samples) { | 431 unsigned min_js_samples) { |
417 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 432 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
418 v8::Local<v8::String> profile_name = v8::String::New("my_profile"); | 433 v8::Local<v8::String> profile_name = v8::String::New("my_profile"); |
419 | 434 |
420 cpu_profiler->StartCpuProfiling(profile_name); | 435 cpu_profiler->StartCpuProfiling(profile_name); |
421 | 436 |
422 i::Sampler* sampler = | 437 i::Sampler* sampler = |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 | 1317 |
1303 CHECK_EQ(1, barNode->GetChildrenCount()); | 1318 CHECK_EQ(1, barNode->GetChildrenCount()); |
1304 const v8::CpuProfileNode* nativeNode2 = GetChild(barNode, "CallJsFunction2"); | 1319 const v8::CpuProfileNode* nativeNode2 = GetChild(barNode, "CallJsFunction2"); |
1305 | 1320 |
1306 CHECK_EQ(1, nativeNode2->GetChildrenCount()); | 1321 CHECK_EQ(1, nativeNode2->GetChildrenCount()); |
1307 GetChild(nativeNode2, "foo"); | 1322 GetChild(nativeNode2, "foo"); |
1308 | 1323 |
1309 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 1324 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
1310 cpu_profiler->DeleteAllCpuProfiles(); | 1325 cpu_profiler->DeleteAllCpuProfiles(); |
1311 } | 1326 } |
OLD | NEW |