Skip to content

Instantly share code, notes, and snippets.

@thomasmichaelwallace
Last active July 27, 2017 18:09
Show Gist options
  • Save thomasmichaelwallace/ac0bf807646fac0758dbf004e0309456 to your computer and use it in GitHub Desktop.
Save thomasmichaelwallace/ac0bf807646fac0758dbf004e0309456 to your computer and use it in GitHub Desktop.
A simple snippet for a time based test.
describe('My awesome new way of doing things', () => {
it('should be performant.' () => {
const maxRunTimeMs = 500;
const start = process.hrtime();
return doSomethingAwesome()
.then(() => {
const runtime = process.hrtime(start);
const runtimeNs = (runtime[0] * 1e9) + runtime[1];
const runtimeMs = runtimeNs / 1e6;
expect(runtimeMs).to.be.lessThan(maxRunTimeMs);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment