Skip to content

Commit

Permalink
Add a test to check the execution overhead.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunabe committed May 12, 2023
1 parent 8becd51 commit 4be149f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/executor.spec.ts
Expand Up @@ -395,6 +395,29 @@ describe("execute", () => {
expect(t0 / t1).toBeGreaterThan(0.5);
});

it("overhead", async () => {
// Check the incremental execution overhead is
// less than 50ms/execution.
expect(
await ex.execute(`
let n = 0;
`)
).toBe(true);
const start = Date.now();
for (let i = 1; i <= 20; ++i) {
expect(
await ex.execute(`
n += ${i};
`)
).toBe(true);
}
const end = Date.now();
expect(end - start).toBeLessThan(1000);
expect(ex.locals).toEqual({
n: 210,
});
});

it("fixed bug#32", async () => {
// https://github.com/yunabe/tslab/issues/32 is reproducible.
expect(await ex.execute(`let b = {}.constructor === Object`)).toBe(true);
Expand Down

0 comments on commit 4be149f

Please sign in to comment.