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 | |
61 void ScriptProfiler::start(const String& title) | 53 void ScriptProfiler::start(const String& title) |
62 { | 54 { |
63 ProfileNameIdleTimeMap* profileNameIdleTimeMap = ScriptProfiler::currentProf
ileNameIdleTimeMap(); | 55 ProfileNameIdleTimeMap* profileNameIdleTimeMap = ScriptProfiler::currentProf
ileNameIdleTimeMap(); |
64 if (profileNameIdleTimeMap->contains(title)) | 56 if (profileNameIdleTimeMap->contains(title)) |
65 return; | 57 return; |
66 profileNameIdleTimeMap->add(title, 0); | 58 profileNameIdleTimeMap->add(title, 0); |
67 | 59 |
68 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 60 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
69 v8::CpuProfiler* profiler = isolate->GetCpuProfiler(); | 61 v8::CpuProfiler* profiler = isolate->GetCpuProfiler(); |
70 if (!profiler) | 62 if (!profiler) |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 } | 304 } |
313 | 305 |
314 void ScriptProfiler::setIdle(bool isIdle) | 306 void ScriptProfiler::setIdle(bool isIdle) |
315 { | 307 { |
316 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 308 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
317 if (v8::CpuProfiler* profiler = isolate->GetCpuProfiler()) | 309 if (v8::CpuProfiler* profiler = isolate->GetCpuProfiler()) |
318 profiler->SetIdle(isIdle); | 310 profiler->SetIdle(isIdle); |
319 } | 311 } |
320 | 312 |
321 } // namespace WebCore | 313 } // namespace WebCore |
OLD | NEW |