OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/renderer/benchmarking_extension.h" | 5 #include "chrome/renderer/benchmarking_extension.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/stats_table.h" | 8 #include "base/metrics/stats_table.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 " this.microseconds = function() {" | 49 " this.microseconds = function() {" |
50 " var stop = stop_;" | 50 " var stop = stop_;" |
51 " if (stop == 0 && start_ != 0)" | 51 " if (stop == 0 && start_ != 0)" |
52 " stop = HiResTime();" | 52 " stop = HiResTime();" |
53 " return Math.ceil(stop - start_);" | 53 " return Math.ceil(stop - start_);" |
54 " };" | 54 " };" |
55 "}" | 55 "}" |
56 ) {} | 56 ) {} |
57 | 57 |
58 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( | 58 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( |
59 v8::Handle<v8::String> name) { | 59 v8::Handle<v8::String> name) OVERRIDE { |
60 if (name->Equals(v8::String::New("GetCounter"))) { | 60 if (name->Equals(v8::String::New("GetCounter"))) { |
61 return v8::FunctionTemplate::New(GetCounter); | 61 return v8::FunctionTemplate::New(GetCounter); |
62 } else if (name->Equals(v8::String::New("IsSingleProcess"))) { | 62 } else if (name->Equals(v8::String::New("IsSingleProcess"))) { |
63 return v8::FunctionTemplate::New(IsSingleProcess); | 63 return v8::FunctionTemplate::New(IsSingleProcess); |
64 } else if (name->Equals(v8::String::New("HiResTime"))) { | 64 } else if (name->Equals(v8::String::New("HiResTime"))) { |
65 return v8::FunctionTemplate::New(HiResTime); | 65 return v8::FunctionTemplate::New(HiResTime); |
66 } | 66 } |
67 | 67 |
68 return v8::Handle<v8::FunctionTemplate>(); | 68 return v8::Handle<v8::FunctionTemplate>(); |
69 } | 69 } |
(...skipping 21 matching lines...) Expand all Loading... |
91 return v8::Number::New( | 91 return v8::Number::New( |
92 static_cast<double>(base::TimeTicks::HighResNow().ToInternalValue())); | 92 static_cast<double>(base::TimeTicks::HighResNow().ToInternalValue())); |
93 } | 93 } |
94 }; | 94 }; |
95 | 95 |
96 v8::Extension* BenchmarkingExtension::Get() { | 96 v8::Extension* BenchmarkingExtension::Get() { |
97 return new BenchmarkingWrapper(); | 97 return new BenchmarkingWrapper(); |
98 } | 98 } |
99 | 99 |
100 } // namespace extensions_v8 | 100 } // namespace extensions_v8 |
OLD | NEW |