1234567891011121314151617181920212223242526 |
- class Benchmark {
- start() {
- this.tstart = process.hrtime();
- return this;
- }
- mark() {
- this.diff = process.hrtime(this.tstart);
- this.tstart = process.hrtime();
-
- return this;
- }
- toString() {
- var msdiff = ( this.diff[0] * 1000000 + this.diff[1] / 1000 ) /1000;
- if(msdiff > 1000)
- return (msdiff / 1000).toFixed(2) + "s";
- else {
- return msdiff.toFixed(2) +"ms";
- }
- return "NaN";
- }
- }
- module.exports = Benchmark;
|