diff options
Diffstat (limited to 'packages/taler-wallet-cli/src/bench1.ts')
-rw-r--r-- | packages/taler-wallet-cli/src/bench1.ts | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/packages/taler-wallet-cli/src/bench1.ts b/packages/taler-wallet-cli/src/bench1.ts index ec0430d8d..3d4561097 100644 --- a/packages/taler-wallet-cli/src/bench1.ts +++ b/packages/taler-wallet-cli/src/bench1.ts @@ -22,6 +22,7 @@ import { codecForNumber, codecForString, codecOptional, + Logger, } from "@gnu-taler/taler-util"; import { getDefaultNodeWallet, @@ -36,14 +37,26 @@ import { * set up its own services. */ export async function runBench1(configJson: any): Promise<void> { + + const logger = new Logger("Bench1"); + // Validate the configuration file for this benchmark. const b1conf = codecForBench1Config().decode(configJson); const myHttpLib = new NodeHttpLib(); + myHttpLib.setThrottling(false); const numIter = b1conf.iterations ?? 1; + const numDeposits = b1conf.deposits ?? 5; + + const withdrawAmount = (numDeposits + 1) * 10; + + logger.info(`Starting Benchmark with ${numIter} Iterations`); for (let i = 0; i < numIter; i++) { + // Create a new wallet in each iteration + // otherwise the TPS go down + // my assumption is that the in-memory db file gets too large const wallet = await getDefaultNodeWallet({ // No persistent DB storage. persistentStoragePath: undefined, @@ -51,8 +64,10 @@ export async function runBench1(configJson: any): Promise<void> { }); await wallet.client.call(WalletApiOperation.InitWallet, {}); + logger.info(`Starting withdrawal of ${withdrawAmount} ${b1conf.currency}`); + await wallet.client.call(WalletApiOperation.WithdrawFakebank, { - amount: "TESTKUDOS:10", + amount: b1conf.currency + ":" + withdrawAmount, bank: b1conf.bank, exchange: b1conf.exchange, }); @@ -61,14 +76,21 @@ export async function runBench1(configJson: any): Promise<void> { stopWhenDone: true, }); - await wallet.client.call(WalletApiOperation.CreateDepositGroup, { - amount: "TESTKUDOS:5", - depositPaytoUri: "payto://x-taler-bank/localhost/foo", - }); + logger.info(`Finished withdrawal`); - await wallet.runTaskLoop({ - stopWhenDone: true, - }); + for (let i = 0; i < numDeposits; i++) { + + logger.info(`Starting deposit of 10 ${b1conf.currency}`); + await wallet.client.call(WalletApiOperation.CreateDepositGroup, { + amount: b1conf.currency + ":10", + depositPaytoUri: b1conf.payto, + }); + + await wallet.runTaskLoop({ + stopWhenDone: true, + }); + logger.info(`Deposit succesful`); + } wallet.stop(); } @@ -84,6 +106,11 @@ interface Bench1Config { bank: string; /** + * Payto url for deposits. + */ + payto: string; + + /** * Base URL of the exchange. */ exchange: string; @@ -93,6 +120,10 @@ interface Bench1Config { * Defaults to 1. */ iterations?: number; + + currency: string; + + deposits?: number; } /** @@ -101,6 +132,9 @@ interface Bench1Config { const codecForBench1Config = () => buildCodecForObject<Bench1Config>() .property("bank", codecForString()) + .property("payto", codecForString()) .property("exchange", codecForString()) .property("iterations", codecOptional(codecForNumber())) + .property("deposits", codecOptional(codecForNumber())) + .property("currency", codecForString()) .build("Bench1Config"); |