Skip to content

Commit

Permalink
Update the example throttle example
Browse files Browse the repository at this point in the history
This update adds the use of throttleCPU into the example test script.
  • Loading branch information
ankur22 committed Nov 9, 2023
1 parent ae27289 commit a786e84
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions examples/throttle.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,21 @@ export const options = {
},
exec: 'throttled',
},
cpuThrottled: {
executor: 'shared-iterations',
options: {
browser: {
type: 'chromium',
},
},
exec: 'cpuThrottled',
},
},
thresholds: {
'browser_http_req_duration{scenario:normal}': ['p(99)<500'],
'browser_http_req_duration{scenario:throttled}': ['p(99)<1500'],
'iteration_duration{scenario:normal}': ['p(99)<3000'],
'iteration_duration{scenario:cpuThrottled}': ['p(99)<6000'],
},
}

Expand Down Expand Up @@ -55,3 +66,16 @@ export async function throttled() {
page.close();
}
}

export async function cpuThrottled() {
const context = browser.newContext();
const page = context.newPage();

try {
page.throttleCPU({ rate: 30 });

await page.goto('https://test.k6.io/', { waitUntil: 'networkidle' });
} finally {
page.close();
}
}

0 comments on commit a786e84

Please sign in to comment.