Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Perf] Include running average in per-second output #13331

Merged
merged 8 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sdk/test-utils/perfstress/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@azure/test-utils-perfstress",
"version": "1.0.0",
"sdk-type": "client",
"description": "Performance and stress test framework for the Azure SDK for JavaScript and TypeScript",
"main": "dist-esm/src/index.js",
"module": "dist-esm/src/index.js",
Expand Down
44 changes: 31 additions & 13 deletions sdk/test-utils/perfstress/src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ export class PerfStressProgram {
}
}

private getCompletedOperations(parallels: PerfStressParallel[]): number {
return parallels.reduce((sum, i) => sum + i.completedOperations, 0);
}

private getOperationsPerSecond(parallels: PerfStressParallel[]): number {
return parallels.reduce((sum, parallel) => {
return sum + parallel.completedOperations / (parallel.lastMillisecondsElapsed / 1000);
}, 0);
}

/**
* Does some calculations based on the parallel executions provided,
* then logs them in a friendly way.
Expand All @@ -82,16 +92,22 @@ export class PerfStressProgram {
* @param parallels Parallel executions
*/
private logResults(parallels: PerfStressParallel[]): void {
const totalOperations = parallels.reduce((sum, i) => sum + i.completedOperations, 0);
const operationsPerSecond = parallels.reduce((sum, parallel) => {
return sum + parallel.completedOperations / (parallel.lastMillisecondsElapsed / 1000);
}, 0);
const totalOperations = this.getCompletedOperations(parallels);
const operationsPerSecond = this.getOperationsPerSecond(parallels);
const secondsPerOperation = 1 / operationsPerSecond;
const weightedAverage = totalOperations / operationsPerSecond;
console.log(
`Completed ${totalOperations} operations in a weighted-average of ${weightedAverage.toFixed(
2
)}s` + ` (${operationsPerSecond.toFixed(2)} ops/s, ${secondsPerOperation.toFixed(3)} s/op)`
`Completed ${totalOperations.toLocaleString(undefined, { maximumFractionDigits: 0 })} ` +
HarshaNalluru marked this conversation as resolved.
Show resolved Hide resolved
`operations in a weighted-average of ` +
`${weightedAverage.toLocaleString(undefined, {
maximumFractionDigits: 2,
minimumFractionDigits: 2
})}s ` +
HarshaNalluru marked this conversation as resolved.
Show resolved Hide resolved
`(${operationsPerSecond.toLocaleString(undefined, { maximumFractionDigits: 2 })} ops/s, ` +
`${secondsPerOperation.toLocaleString(undefined, {
maximumFractionDigits: 3,
minimumFractionDigits: 3
})} s/op)`
HarshaNalluru marked this conversation as resolved.
Show resolved Hide resolved
);
}

Expand Down Expand Up @@ -204,13 +220,15 @@ export class PerfStressProgram {
`\n=== ${title} mode, iteration ${iterationIndex}. Logs every ${millisecondsToLog /
1000}s ===`
);
console.log(`Since Last Log\t\tTotal`);
let lastInIteration = 0;
console.log(`Current\t\tTotal\t\tAverage`);
mikeharder marked this conversation as resolved.
Show resolved Hide resolved
let lastCompleted = 0;
const logInterval = setInterval(() => {
const inTotal = parallels.reduce((sum, i) => sum + i.completedOperations, 0);
const sinceLastLog = inTotal - lastInIteration;
console.log(sinceLastLog + "\t\t\t" + inTotal);
lastInIteration = inTotal;
const totalCompleted = this.getCompletedOperations(parallels);
const currentCompleted = totalCompleted - lastCompleted;
const averageCompleted = this.getOperationsPerSecond(parallels);

lastCompleted = totalCompleted;
console.log(`${currentCompleted}\t\t${totalCompleted}\t\t${averageCompleted.toFixed(2)}`);
}, millisecondsToLog);

const isAsync = !this.parsedDefaultOptions.sync.value;
Expand Down