Skip to content

Instantly share code, notes, and snippets.

@jkuester
Created June 27, 2023 13:06
Show Gist options
  • Save jkuester/90318324e1c2f80eaf24a15ebac4656d to your computer and use it in GitHub Desktop.
Save jkuester/90318324e1c2f80eaf24a15ebac4656d to your computer and use it in GitHub Desktop.
PED Performance Test
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