Skip to content

Commit

Permalink
rm init
Browse files Browse the repository at this point in the history
  • Loading branch information
albho committed Feb 15, 2024
1 parent 3aea0d9 commit 480ad90
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/web-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ jobs:
node-version: [ lts/* ]
include:
- node-version: lts/*
num_test_iterations: 5
init_performance_threshold_sec: 5
proc_performance_threshold_sec: 15
num_test_iterations: 10
proc_performance_threshold_sec: 10

steps:
- uses: actions/checkout@v3
Expand All @@ -56,4 +55,4 @@ jobs:
run: yarn setup-test

- name: Test
run: yarn test-perf --env ACCESS_KEY=${{secrets.PV_VALID_ACCESS_KEY}},NUM_TEST_ITERATIONS=${{matrix.num_test_iterations}},INIT_PERFORMANCE_THRESHOLD_SEC=${{matrix.init_performance_threshold_sec}},PROC_PERFORMANCE_THRESHOLD_SEC=${{matrix.proc_performance_threshold_sec}}
run: yarn test-perf --env ACCESS_KEY=${{secrets.PV_VALID_ACCESS_KEY}},NUM_TEST_ITERATIONS=${{matrix.num_test_iterations}},PROC_PERFORMANCE_THRESHOLD_SEC=${{matrix.proc_performance_threshold_sec}}
5 changes: 2 additions & 3 deletions binding/web/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { defineConfig } from 'cypress';

export default defineConfig({
env: {
'NUM_TEST_ITERATIONS': 5,
'INIT_PERFORMANCE_THRESHOLD_SEC': 3,
'PROC_PERFORMANCE_THRESHOLD_SEC': 5,
'NUM_TEST_ITERATIONS': 10,
'PROC_PERFORMANCE_THRESHOLD_SEC': 10,
},
e2e: {
defaultCommandTimeout: 30000,
Expand Down
13 changes: 2 additions & 11 deletions binding/web/test/orca_perf.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@ import testData from '../cypress/fixtures/.test/test_data.json';

const ACCESS_KEY = Cypress.env('ACCESS_KEY');
const NUM_TEST_ITERATIONS = Number(Cypress.env('NUM_TEST_ITERATIONS'));
const INIT_PERFORMANCE_THRESHOLD_SEC = Number(Cypress.env('INIT_PERFORMANCE_THRESHOLD_SEC'));
const PROC_PERFORMANCE_THRESHOLD_SEC = Number(Cypress.env('PROC_PERFORMANCE_THRESHOLD_SEC'));

async function testPerformance(
instance: typeof Orca | typeof OrcaWorker,
publicPath: string,
text: string,
) {
const initPerfResults: number[] = [];
const procPerfResults: number[] = [];

for (let j = 0; j < NUM_TEST_ITERATIONS; j++) {
let isSynthesized = false;

let start = Date.now();
const orca = await instance.create(
ACCESS_KEY,
orcaTranscript => {
Expand All @@ -27,8 +24,6 @@ async function testPerformance(
},
{ publicPath: publicPath, forceWrite: true },
);
let end = Date.now();
initPerfResults.push((end - start) / 1000);

const waitUntil = (): Promise<void> =>
new Promise(resolve => {
Expand All @@ -39,10 +34,10 @@ async function testPerformance(
}, 100);
});

start = Date.now();
let start = Date.now();
await orca.synthesize(text);
await waitUntil();
end = Date.now();
let end = Date.now();
procPerfResults.push((end - start) / 1000);

if (orca instanceof OrcaWorker) {
Expand All @@ -52,15 +47,11 @@ async function testPerformance(
}
}

const initAvgPerf = initPerfResults.reduce((a, b) => a + b) / NUM_TEST_ITERATIONS;
const procAvgPerf = procPerfResults.reduce((a, b) => a + b) / NUM_TEST_ITERATIONS;

// eslint-disable-next-line no-console
console.log(`Average init performance: ${initAvgPerf} seconds`);
// eslint-disable-next-line no-console
console.log(`Average proc performance: ${procAvgPerf} seconds`);

expect(initAvgPerf).to.be.lessThan(INIT_PERFORMANCE_THRESHOLD_SEC);
expect(procAvgPerf).to.be.lessThan(PROC_PERFORMANCE_THRESHOLD_SEC);
}

Expand Down

0 comments on commit 480ad90

Please sign in to comment.