-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add tooling for standalone performance benchmarks
- Loading branch information
Showing
6 changed files
with
694 additions
and
106 deletions.
There are no files selected for viewing
85 changes: 0 additions & 85 deletions
85
packages/boot/test/bootstrapTests/bench-vaults-stripped.js
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// This is a version of bench-vaults-performance.js designed to run as a | ||
// standalone node executable, without reference to Ava, using the | ||
// benchmarkerator module. It has had all intrinsic performance measurement | ||
// code stripped out of it, purely implementing the vault benchmark test code in | ||
// expectation of extrinsic measurement. | ||
|
||
import { bench } from './benchmarkerator.js'; | ||
|
||
// eslint-disable-next-line import/order | ||
import { Offers } from '@agoric/inter-protocol/src/clientSupport.js'; | ||
|
||
const collateralBrandKey = 'ATOM'; | ||
|
||
bench.addBenchmark('vault open', { | ||
executeRound: async (context, round) => { | ||
const { alice } = context.actors; | ||
|
||
const openVault = async (i, n, r) => { | ||
const offerId = `open-vault-${i}-of-${n}-round-${r}`; | ||
await alice.executeOfferMaker(Offers.vaults.OpenVault, { | ||
offerId, | ||
collateralBrandKey, | ||
wantMinted: 5, | ||
giveCollateral: 1.0, | ||
}); | ||
|
||
const upd = alice.getLatestUpdateRecord(); | ||
assert( | ||
upd.updated === 'offerStatus' && | ||
upd.status.id === offerId && | ||
upd.status.numWantsSatisfied === 1, | ||
); | ||
}; | ||
|
||
const openN = async n => { | ||
const range = [...Array(n)].map((_, i) => i + 1); | ||
await Promise.all(range.map(i => openVault(i, n, round))); | ||
}; | ||
|
||
const roundSize = context.params.size ? Number(context.params.size) : 1; | ||
await openN(roundSize); | ||
}, | ||
}); | ||
|
||
await bench.run('vaults'); |
Oops, something went wrong.