GithubHelp home page GithubHelp logo

isabella232 / buffer-js-chronos Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bufferapp/buffer-js-chronos

0.0 0.0 0.0 32 KB

A small library to handle browsers timing api

License: MIT License

JavaScript 100.00%

buffer-js-chronos's Introduction

Chronos

A small library to handle browser timining measures

How To

install it

npm i --save @bufferapp/chronos
import chronos from '@bufferapp/chronos';
const ch = chronos();

The simplest way to measure something is to start the measure with ch.startMeasure('bar') and then stop it ch.stopMeasure('bar'). To store the measure you should define a storing method when you instatiate Chronos passing it down in the configuration options

const ch = chronos({
  store: (data) => {
    …
  }
})

When that is provided Chronos will auto save the measures for you. Chronos is using requestIdleCallback to parse and store measures, so autosave won't effect your app performances, anyway you are free to disable this behaviour setting autoSave: false in the options. In this case you can manually save measures with ch.saveToStore().

You can measure anything against browser timing event with ch.measureFromSpecialEvent({ name: 'foo', eventName: 'navigationStart' }), there is also a convenient method to measure against Navigation Start ch.measureFromNavigationStart('foo').

If you want to store any extra data along with your measures you can pass a data object in measure start options ch.startMeasure({name: 'foo', data: {tags: ['foo', 'bar']}}), the data field will be passed down to your store method.

Happy measuring!

buffer-js-chronos's People

Contributors

federicoweber 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.