Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(623)

Unified Diff: webkit/extensions/v8/benchmarking_extension.cc

Issue 3126029: Move the chromium.Interval to chrome.Interval as part of the benchmarking... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: One more missing file!! Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/render_thread.cc ('k') | webkit/extensions/v8/interval_extension.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/extensions/v8/benchmarking_extension.cc
===================================================================
--- webkit/extensions/v8/benchmarking_extension.cc (revision 57339)
+++ webkit/extensions/v8/benchmarking_extension.cc (working copy)
@@ -4,6 +4,7 @@
#include "base/command_line.h"
#include "base/stats_table.h"
+#include "base/time.h"
#include "net/http/http_network_layer.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCache.h"
#include "webkit/extensions/v8/benchmarking_extension.h"
@@ -45,6 +46,26 @@
" native function IsSingleProcess();"
" return IsSingleProcess();"
"};"
+ "chrome.Interval = function() {"
+ " var start_ = 0;"
+ " var stop_ = 0;"
+ " native function HiResTime();"
+ " this.start = function() {"
+ " stop_ = 0;"
+ " start_ = HiResTime();"
+ " };"
+ " this.stop = function() {"
+ " stop_ = HiResTime();"
+ " if (start_ == 0)"
+ " stop_ = 0;"
+ " };"
+ " this.microseconds = function() {"
+ " var stop = stop_;"
+ " if (stop == 0 && start_ != 0)"
+ " stop = HiResTime();"
+ " return Math.ceil(stop - start_);"
+ " };"
+ "}"
) {}
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
@@ -59,7 +80,10 @@
return v8::FunctionTemplate::New(GetCounter);
} else if (name->Equals(v8::String::New("IsSingleProcess"))) {
return v8::FunctionTemplate::New(IsSingleProcess);
+ } else if (name->Equals(v8::String::New("HiResTime"))) {
+ return v8::FunctionTemplate::New(HiResTime);
}
+
return v8::Handle<v8::FunctionTemplate>();
}
@@ -99,6 +123,11 @@
static v8::Handle<v8::Value> IsSingleProcess(const v8::Arguments& args) {
return v8::Boolean::New(webkit_glue::IsSingleProcess());
}
+
+ static v8::Handle<v8::Value> HiResTime(const v8::Arguments& args) {
+ return v8::Number::New(
+ static_cast<double>(base::TimeTicks::HighResNow().ToInternalValue()));
+ }
};
v8::Extension* BenchmarkingExtension::Get() {
« no previous file with comments | « chrome/renderer/render_thread.cc ('k') | webkit/extensions/v8/interval_extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698