Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nanotiming

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nanotiming

Small timing library

  • 3.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
67K
increased by17.28%
Maintainers
1
Weekly downloads
 
Created
Source

nanotiming stability

npm version build status downloads js-standard-style

Small timing library. Useful to integrate into libraries that have multiple methods. Only works in the browser, does nothing in Node.

Usage

var nanotiming = require('nanotiming')
var timing = nanotiming('my-timing')

timing.start('my-loop')
var i = 1000
while (--i) console.log(i)
timing.end('my-loop')

// Process marks when we have spare time available
window.requestIdleCallback(function () {
  var name = 'my-timing/my-loop'
  var timings = window.performance.getEntriesByName(name)
  console.log(timings[timings.length - 1]) // log the last entry
  performance.clearMeasures(name)          // be a good citizen and free up memory
})

API

timing = nanotiming([instanceName])

Create a new Nanotiming instance. Takes a name for the timing instance.

uuid = timing.start([methodName])

Start a timing. Takes a method name. The method name is concatenated to the instance name as <instanceName>/<methodName>. If no method name is passed, it'll fall back to only using the instance name. It's recommended that per instance to either always use method names, or never.

Returns a uuid that should be passed to timing.end() so async timings work.

timing.end(uuid, [methodName])

End a timing. The name here must be the same as timing.start(). If you want to do use this in async conditions make sure the name is unique, for example by appending a unique id to both start and end. The performance.measure() step is performed in a requestIdleCallback() tick, so make sure to process measures asynchronously, and preferably in later idle callbacks.

Takes the uuid that is povided by timing.start() so async timings work.

License

MIT

Keywords

FAQs

Package last updated on 16 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc