GithubHelp home page GithubHelp logo

precisetime's Introduction

preciseTime

JavaScriptCore has a handy global function called preciseTime() which aim is to provide a double, based on time, precise enough to ensure microseconds, but not as greedy as Java nanoTime in therms of clock. This precision has been proposed in W3C but is not available yet.

Since JSC offers this natively, the aim of this little script is to normalize this function that specially when it comes to benchmarks or asynchronous queue ordered by execution time, could be all we need.

The node.js version might require microtime if process.hrtime() is not supported. I have not set the dependency since that module has bindings and it might be more problematic to install.

Browsers that do not implement HighResolutionTime will simply return new Date / 1000 to be consistent with other results.

How To Use

  • in node.js npm install precisetime then var preciseTime = require("precisetime").preciseTime
  • in Rhino just load/include the precisetime.js file inside the build folder
  • in JSC you don't need to do anything
  • in browsers or other envs, load/require/include precisetime.js inside the build

This is pretty much it

precisetime's People

Contributors

webreflection avatar kentaromiura avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.