0.0.9 • Published 8 years ago

exec-timer v0.0.9

Weekly downloads
1
License
ISC
Repository
github
Last release
8 years ago

Execution Timer

Measure execution time of functions and promises in Milliseconds

npm install exec-timer

const timer = require('exec-timer');
function f (param1, param2) {
    return `f -> ${param1}+${param2}`;
}

let result = timer.measure('function f()', (end) => {
    end();
    return f('a', 'b');
});

console.log(timer.get('function f()'));
function cb (param1, param2, callback) {
    setTimeout(() => {
        callback(`cb -> ${param1}+${param2}`);
    }, 500);
}

timer.measure('function cb()', (end) => {
    cb('c', 'd', data => {
        end();

        console.log(timer.get('function cb()'));
    });
});
timer.measure('promise', new Promise((resolve, reject) => {
    setTimeout(() => {
        resolve('promise -> resolved');
    }, 200);
})).then(data => {
    console.log(timer.get('promise'));
}).catch(error => {
    console.log(timer.get('promise'));
});
timer.start('measure');
// Some code
timer.end('measure');

Get all measures

timer.get(); // Map
timer.get().toObject() // Object
0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago