wallet-cli: run benchmark in a loop

This commit is contained in:
Florian Dold 2021-10-20 13:27:47 +02:00
parent 589c2a3382
commit cf25f5698e
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B

View File

@ -17,7 +17,12 @@
/** /**
* Imports. * Imports.
*/ */
import { buildCodecForObject, codecForString } from "@gnu-taler/taler-util"; import {
buildCodecForObject,
codecForNumber,
codecForString,
codecOptional,
} from "@gnu-taler/taler-util";
import { import {
getDefaultNodeWallet, getDefaultNodeWallet,
NodeHttpLib, NodeHttpLib,
@ -42,24 +47,28 @@ export async function runBench1(configJson: any): Promise<void> {
}); });
await wallet.client.call(WalletApiOperation.InitWallet, {}); await wallet.client.call(WalletApiOperation.InitWallet, {});
await wallet.client.call(WalletApiOperation.WithdrawFakebank, { const numIter = b1conf.iterations ?? 1;
amount: "TESTKUDOS:10",
bank: b1conf.bank,
exchange: b1conf.exchange,
});
await wallet.runTaskLoop({ for (let i = 0; i < numIter; i++) {
stopWhenDone: true, await wallet.client.call(WalletApiOperation.WithdrawFakebank, {
}); amount: "TESTKUDOS:10",
bank: b1conf.bank,
exchange: b1conf.exchange,
});
await wallet.client.call(WalletApiOperation.CreateDepositGroup, { await wallet.runTaskLoop({
amount: "TESTKUDOS:5", stopWhenDone: true,
depositPaytoUri: "payto://x-taler-bank/localhost/foo", });
});
await wallet.runTaskLoop({ await wallet.client.call(WalletApiOperation.CreateDepositGroup, {
stopWhenDone: true, amount: "TESTKUDOS:5",
}); depositPaytoUri: "payto://x-taler-bank/localhost/foo",
});
await wallet.runTaskLoop({
stopWhenDone: true,
});
}
wallet.stop(); wallet.stop();
} }
@ -77,6 +86,12 @@ interface Bench1Config {
* Base URL of the exchange. * Base URL of the exchange.
*/ */
exchange: string; exchange: string;
/**
* How many withdraw/deposit iterations should be made?
* Defaults to 1.
*/
iterations?: number;
} }
/** /**
@ -86,4 +101,5 @@ const codecForBench1Config = () =>
buildCodecForObject<Bench1Config>() buildCodecForObject<Bench1Config>()
.property("bank", codecForString()) .property("bank", codecForString())
.property("exchange", codecForString()) .property("exchange", codecForString())
.property("iterations", codecOptional(codecForNumber()))
.build("Bench1Config"); .build("Bench1Config");