Created
June 27, 2023 13:06
-
-
Save jkuester/90318324e1c2f80eaf24a15ebac4656d to your computer and use it in GitHub Desktop.
PED Performance Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { expect } = require('chai'); | |
const TestRunner = require('cht-conf-test-harness'); | |
const harness = new TestRunner(); | |
const ITERATIONS = 10; | |
const PED_INPUTS = [ | |
[], | |
[], | |
['hp410001'], | |
['opt_none'], | |
['No'], // May need ok select here... | |
['opt_none', 'opt_none', 'opt_none'], | |
['2', 'male', 5, 40], | |
['green', 70, 'Yes'], | |
[], | |
[], | |
[], | |
['opt_1', 'opt_1', 'opt_1'] | |
]; | |
const performanceResults = []; | |
describe('PED form', () => { | |
before(() => harness.start()); | |
after(() => harness.stop()); | |
beforeEach( | |
async() => { | |
await harness.clear(); | |
}); | |
afterEach(() => expect(harness.consoleErrors).to.be.empty); | |
Array.from({length: ITERATIONS}).forEach((_, i) => { | |
it(`Iteration: ${i}`, async () => { | |
const start = Date.now(); | |
const result = await harness.fillForm('ped', ...PED_INPUTS); | |
expect(result.errors).to.be.empty; | |
const end = Date.now(); | |
performanceResults.push(end - start); | |
}).timeout(100000000); | |
}); | |
it('Results:', () => { | |
const averageRuntime = performanceResults.reduce((a, b) => a + b, 0) / performanceResults.length; | |
const minRuntime = Math.min(...performanceResults); | |
const maxRuntime = Math.max(...performanceResults); | |
console.log(`Average runtime: ${averageRuntime}ms`); | |
console.log(`Min runtime: ${minRuntime}ms`); | |
console.log(`Max runtime: ${maxRuntime}ms`); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment