Skip to content

Commit

Permalink
fix: calculate task time out of try-catch block
Browse files Browse the repository at this point in the history
  • Loading branch information
kainstar authored and Aslemammad committed Oct 18, 2022
1 parent bd15cf8 commit 74c5c0c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ export default class Task extends EventTarget {
} else {
this.fn();
}
const taskTime = this.bench.now() - taskStart;
this.runs += 1;
samples.push(taskTime);
totalTime += taskTime;
} catch (e) {
this.setResult({ error: e });
}

const taskTime = this.bench.now() - taskStart;
this.runs += 1;
samples.push(taskTime);
totalTime += taskTime;
}
await this.bench.teardown(this, 'run');

Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Fn } from 'types';
import type { Fn } from 'types/index';

export const nanoToMs = (nano: number) => nano / 1e6;

Expand Down

0 comments on commit 74c5c0c

Please sign in to comment.