| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011, Google Inc. All rights reserved. | 2 * Copyright (c) 2011, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 #include <v8-profiler.h> | 44 #include <v8-profiler.h> |
| 45 #include <v8.h> | 45 #include <v8.h> |
| 46 | 46 |
| 47 #include "wtf/ThreadSpecific.h" | 47 #include "wtf/ThreadSpecific.h" |
| 48 | 48 |
| 49 namespace WebCore { | 49 namespace WebCore { |
| 50 | 50 |
| 51 typedef HashMap<String, double> ProfileNameIdleTimeMap; | 51 typedef HashMap<String, double> ProfileNameIdleTimeMap; |
| 52 | 52 |
| 53 void ScriptProfiler::setSamplingInterval(int intervalUs) |
| 54 { |
| 55 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 56 v8::CpuProfiler* profiler = isolate->GetCpuProfiler(); |
| 57 if (profiler) |
| 58 profiler->SetSamplingInterval(intervalUs); |
| 59 } |
| 60 |
| 53 void ScriptProfiler::start(const String& title) | 61 void ScriptProfiler::start(const String& title) |
| 54 { | 62 { |
| 55 ProfileNameIdleTimeMap* profileNameIdleTimeMap = ScriptProfiler::currentProf
ileNameIdleTimeMap(); | 63 ProfileNameIdleTimeMap* profileNameIdleTimeMap = ScriptProfiler::currentProf
ileNameIdleTimeMap(); |
| 56 if (profileNameIdleTimeMap->contains(title)) | 64 if (profileNameIdleTimeMap->contains(title)) |
| 57 return; | 65 return; |
| 58 profileNameIdleTimeMap->add(title, 0); | 66 profileNameIdleTimeMap->add(title, 0); |
| 59 | 67 |
| 60 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 68 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 61 v8::CpuProfiler* profiler = isolate->GetCpuProfiler(); | 69 v8::CpuProfiler* profiler = isolate->GetCpuProfiler(); |
| 62 if (!profiler) | 70 if (!profiler) |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } | 312 } |
| 305 | 313 |
| 306 void ScriptProfiler::setIdle(bool isIdle) | 314 void ScriptProfiler::setIdle(bool isIdle) |
| 307 { | 315 { |
| 308 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 316 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 309 if (v8::CpuProfiler* profiler = isolate->GetCpuProfiler()) | 317 if (v8::CpuProfiler* profiler = isolate->GetCpuProfiler()) |
| 310 profiler->SetIdle(isIdle); | 318 profiler->SetIdle(isIdle); |
| 311 } | 319 } |
| 312 | 320 |
| 313 } // namespace WebCore | 321 } // namespace WebCore |
| OLD | NEW |