Skip to content

Commit

Permalink
feat(common): add simple util to log benchmarks (#2027)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvrs authored Dec 7, 2023
1 parent c8ffd09 commit ffcf64e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/common/src/createBenchmark.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import createDebug from "debug";

export function createBenchmark(namespace: string): (stepName: string) => void {
const debug = createDebug("mud:benchmark:" + namespace);
let lastStep = performance.now();

return (stepName: string) => {
const secondsSinceLastStep = (performance.now() - lastStep) / 1000;
debug("%s: +%ds", stepName, secondsSinceLastStep);
lastStep = performance.now();
};
}
1 change: 1 addition & 0 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from "./common";
export * from "./createBenchmark";
export * from "./createBurnerAccount";
export * from "./createNonceManager";
export * from "./getContract";
Expand Down

0 comments on commit ffcf64e

Please sign in to comment.