Skip to content

Commit

Permalink
test: improve benchmark test stability
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Oct 28, 2022
1 parent 8ac3d47 commit 6beaf42
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions test/benchmark/test.mjs
Expand Up @@ -13,6 +13,11 @@ await execa('npx', ['vitest', 'bench', 'base.bench', 'mode.bench', 'only.bench']
error = e
})

if (error) {
console.error(error)
process.exit(1)
}

const benchResult = await readFile('./bench.json', 'utf-8')

if (benchResult.includes('skip'))
Expand All @@ -26,9 +31,4 @@ const todoBenches = ['unimplemented suite', 'unimplemented test']
if (todoBenches.some(b => benchResult.includes(b)))
process.exit(1)

if (error) {
console.error(error)
process.exit(1)
}

process.exit(0)
6 changes: 3 additions & 3 deletions test/benchmark/test/base.bench.ts
Expand Up @@ -6,17 +6,17 @@ describe('sort', () => {
x.sort((a, b) => {
return a - b
})
})
}, { iterations: 5, time: 0 })

bench('reverse', () => {
const x = [1, 5, 4, 2, 3]
x.reverse().sort((a, b) => {
return a - b
})
})
}, { iterations: 5, time: 0 })

// TODO: move to failed tests
// should not be collect
// should not be collected
// it('test', () => {
// expect(1 + 1).toBe(3)
// })
Expand Down
10 changes: 5 additions & 5 deletions test/benchmark/test/only.bench.ts
Expand Up @@ -6,7 +6,7 @@ const run = [false, false, false, false, false]
describe('a0', () => {
bench.only('0', () => {
run[0] = true
})
}, { iterations: 1, time: 0 })
bench('s0', () => {
expect(true).toBe(false)
})
Expand All @@ -17,7 +17,7 @@ describe('a1', () => {
describe('c1', () => {
bench.only('1', () => {
run[1] = true
})
}, { iterations: 1, time: 0 })
})
bench('s1', () => {
expect(true).toBe(false)
Expand All @@ -28,7 +28,7 @@ describe('a1', () => {
describe.only('a2', () => {
bench('2', () => {
run[2] = true
})
}, { iterations: 1, time: 0 })
})

bench('s2', () => {
Expand All @@ -39,7 +39,7 @@ describe.only('a3', () => {
describe('b3', () => {
bench('3', () => {
run[3] = true
})
}, { iterations: 1, time: 0 })
})
bench.skip('s3', () => {
expect(true).toBe(false)
Expand All @@ -50,7 +50,7 @@ describe('a4', () => {
describe.only('b4', () => {
bench('4', () => {
run[4] = true
})
}, { iterations: 1, time: 0 })
})
describe('sb4', () => {
bench('s4', () => {
Expand Down

0 comments on commit 6beaf42

Please sign in to comment.