Skip to content

Commit

Permalink
feat: Add tooling for standalone performance benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
FUDCo committed Sep 7, 2023
1 parent f36ed85 commit e082299
Show file tree
Hide file tree
Showing 6 changed files with 694 additions and 106 deletions.
85 changes: 0 additions & 85 deletions packages/boot/test/bootstrapTests/bench-vaults-stripped.js

This file was deleted.

45 changes: 45 additions & 0 deletions packages/boot/test/bootstrapTests/benchmark-vaults.js
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');
Loading

0 comments on commit e082299

Please sign in to comment.