Bug 1439788 - Add performance.now() function to JS shell. r=arai
authorDhi Aurrahman <diorahman@rockybars.com>
Sat, 03 Mar 2018 18:01:45 +0700
changeset 409584 c59eff0e8209d2a672eb4b39c9fe0f650b386dc7
parent 409583 1caa948c67f3df85926787b8a5817c78b0275eb9
child 409585 b9f68d98cf4195bcca30015c272c37f19f9dd71a
push id33693
push usernbeleuzu@mozilla.com
push dateFri, 23 Mar 2018 09:52:16 +0000
treeherdermozilla-central@9cb650de48f9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1439788
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1439788 - Add performance.now() function to JS shell. r=arai
js/src/shell/js.cpp
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -7452,16 +7452,24 @@ TestAssertRecoveredOnBailout,
     JS_FN_HELP("setBufferStreamParams", SetBufferStreamParams, 2, 0,
 "setBufferStreamParams(delayMillis, chunkByteSize)",
 "  Set the delay time (between calls to StreamConsumer::consumeChunk) and chunk\n"
 "  size (in bytes)."),
 
     JS_FS_HELP_END
 };
 
+static const JSFunctionSpecWithHelp performance_functions[] = {
+    JS_FN_HELP("now", Now, 0, 0,
+"now()",
+"  Return the current time with sub-ms precision.\n"
+"  This function is an alias of the dateNow() function."),
+    JS_FS_HELP_END
+};
+
 static const JSFunctionSpecWithHelp console_functions[] = {
     JS_FN_HELP("log", Print, 0, 0,
 "log([exp ...])",
 "  Evaluate and print expressions to stdout.\n"
 "  This function is an alias of the print() function."),
     JS_FS_HELP_END
 };
 
@@ -8380,16 +8388,18 @@ NewGlobalObject(JSContext* cx, JS::Compa
         }
 
         if (!DefineOS(cx, glob, fuzzingSafe, &gOutFile, &gErrFile))
             return nullptr;
 
         RootedObject performanceObj(cx, JS_NewObject(cx, nullptr));
         if (!performanceObj)
             return nullptr;
+        if (!JS_DefineFunctionsWithHelp(cx, performanceObj, performance_functions))
+            return nullptr;
         RootedObject mozMemoryObj(cx, JS_NewObject(cx, nullptr));
         if (!mozMemoryObj)
             return nullptr;
         RootedObject gcObj(cx, gc::NewMemoryInfoObject(cx));
         if (!gcObj)
             return nullptr;
         if (!JS_DefineProperty(cx, glob, "performance", performanceObj, JSPROP_ENUMERATE))
             return nullptr;