Skip to content

ekarak/frequency-meter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frequency Meter Build Status

Measures the frequency of events. This is a slightly modified version off pgte's initial code. My version has a more deterministic output, as the original version used dynamic rescheduling of count periods which produced significant skew after the first few minutes of operation.

Install

$ npm install https://github.com/ekarak/frequency-meter

Use

Require:

var FM = require('frequency-meter');

Construct:

var fm = FM();

or construct with explicit measuring and notifications intervals (both default to 1 second):

var fm = FM(60000, 5000); // calculate frequency for events occuring in the previous 1 minute, report frequency every 5 seconds

Feed it events:

setInterval(function() {
  fm.happened();
}, 100);

And listen for frequency updates:

fm.on('frequency', function(freq) {
  console.log('frequency is', freq);
});

End it:

fm.end();

License

MIT

About

Measures event frequency

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%