-
-
Save raine/f97f58f680ae71de7218 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const measurePromise = (p, cb) => { | |
const elapsed = hirestime(); | |
p.then(() => cb(elapsed())); | |
return p; | |
}; | |
const measurePromiseFn = (fn, cb) => | |
(...args) => measurePromise(fn.apply(null, args), cb); | |
const measure = (metric, fn) => | |
measurePromiseFn(fn, (ms) => metrics.timing(metric, ms)); | |
/* or partial(metrics.timing, metric) */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment