npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

chronographjs

v0.1.3

Published

A small nano timer for NodeJS applications based on proccess.hrtime

Downloads

24

Readme

chronographjs

A small nano timer for NodeJS applications based on proccess.hrtime

npm i chronographjs --save

To see the power run:

node
> var tst = require('chronographjs');
> tst.runExample();

More detailed example

You can see the code that runs tst.runExample() bellow or you can check it here

var chronographjs = require('chronographjs');
var timer = new chronographjs.getTimer();

timer.start('t1', 'cache_check');
for (let i = 1; i < 1000000; i++) {}
timer.stop('t1');

timer.start('t2', 'select,main_database,db');
for (let i = 1; i < 1000000; i++) {}
timer.stop('t2');

timer.start('t3', 'raw_compute');
for (let i = 1; i < 1500000; i++) {}
timer.stop('t3');

timer.start('t4', 'insert,main_database,db');
for (let i = 1; i < 1000000; i++) {}
timer.stop('t4');

timer.start('t5', 'insert,log_database,db');
for (let i = 1; i < 100; i++) {}
timer.stop('t5');

console.log('Our total processing time until now is %s', timer.total().msecs(true));
console.log('Code block t1 took %s', timer.time('t1').msecs(true));
console.log('Code block t2 took %s', timer.time('t2').msecs(true));
console.log('Code block t3 took %s', timer.time('t3').msecs(true));
console.log('Code block t4 took %s', timer.time('t4').msecs(true));
console.log('Code block t5 took %s', timer.time('t5').usecs(true));
console.log('We spent a total of %s in the database', timer.total('db').msecs(true));
console.log('From that time, %s were selects', timer.total('select').msecs(true));
console.log('%s were inserts', timer.total('insert').msecs(true));
console.log('%s in the main database', timer.total('main_database').msecs(true));
console.log('%s in the log database', timer.total('log_database').msecs(true));
console.log('we also blocked for %s in raw compute', timer.total('raw_compute').msecs(true));
var total = timer.total();
console.log('With all our console logs we took a total of %s or %s or %s or %s', total.secs(true), total.msecs(true), total.usecs(true), total.nsecs(true));

The above code will give you something like this:

Running example.es6
Our total processing time until now is 12.266026 ms
Code block t1 took 6.152425 ms
Code block t2 took 1.730105 ms
Code block t3 took 2.58467 ms
Code block t4 took 1.672985 ms
Code block t5 took 2.231 us
We spent a total of 3.405321 ms in the database
From that time, 1.730105 ms were selects
1.675216 ms were inserts
3.40309 ms in the main database
0.002231 ms in the log database
we also blocked for 2.58467 ms in raw compute
With all our console logs we took a total of 0.01429958 s or 14.29958 ms or 14299.58 us or 14299580 ns