The short answer: No.

Execution time of Javascript code is highly dependent on a number of 
factors, the largest and most varied is the garbage collector.  It's fairly 
easy to come up with code which, when ran and timed a large number of 
times, is orders of magnitude slower some of those times, depending on how 
much work the garbage collector decides to do during allocations during the 
run.  And, in Javascript, nearly *everything* creates allocations and 
garbage.

The most reliable sandboxing would probably be to start an entirely 
separate process, but even that, I suspect, will be pretty highly variable 
in terms of performance (and, of course, have huge amounts of overhead if 
the Javascript you're running is relatively small).

On Thursday, September 24, 2015 at 8:24:22 AM UTC-7, Mon wrote:
>
> Is it possible to sandbox a JavaScript program running on top of nodejs so 
> that execution time reported using "process.hrtime()" will not vary much 
> across executions?
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/e69d5075-dbcc-4494-b481-280ddc42c635%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to