aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-cli
diff options
context:
space:
mode:
authorBoss Marco <bossm8@bfh.ch>2021-11-18 13:50:11 +0100
committerBoss Marco <bossm8@bfh.ch>2021-11-18 13:52:24 +0100
commit525fcc48dcb9c810efe99ad15efb5446df77ac35 (patch)
treebf476da64fd2d8cbb115702a777cfd4fee924fe0 /packages/taler-wallet-cli
parent9f0429cb2f8ad9cb2e98a787139602d913c1aefa (diff)
parentf8c0242f5306cccd52b0f9432b5acbb63fa38e08 (diff)
Merge benchmark implementation for Grid5000
Diffstat (limited to 'packages/taler-wallet-cli')
-rw-r--r--packages/taler-wallet-cli/src/bench1.ts81
1 files changed, 66 insertions, 15 deletions
diff --git a/packages/taler-wallet-cli/src/bench1.ts b/packages/taler-wallet-cli/src/bench1.ts
index ad95eebc7..30ef8732f 100644
--- a/packages/taler-wallet-cli/src/bench1.ts
+++ b/packages/taler-wallet-cli/src/bench1.ts
@@ -22,11 +22,13 @@ import {
codecForNumber,
codecForString,
codecOptional,
+ Logger,
} from "@gnu-taler/taler-util";
import {
getDefaultNodeWallet,
NodeHttpLib,
WalletApiOperation,
+ Wallet,
} from "@gnu-taler/taler-wallet-core";
/**
@@ -36,6 +38,9 @@ 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);
@@ -43,17 +48,36 @@ export async function runBench1(configJson: any): Promise<void> {
myHttpLib.setThrottling(false);
const numIter = b1conf.iterations ?? 1;
+ const numDeposits = b1conf.deposits ?? 5;
+ const restartWallet = b1conf.restartAfter ?? 20;
+
+ const withdrawAmount = (numDeposits + 1) * 10;
+
+ logger.info(`Starting Benchmark iterations=${numIter} deposits=${numDeposits}`);
+
+ let wallet = {} as Wallet;
for (let i = 0; i < numIter; i++) {
- const wallet = await getDefaultNodeWallet({
- // No persistent DB storage.
- persistentStoragePath: undefined,
- httpLib: myHttpLib,
- });
- await wallet.client.call(WalletApiOperation.InitWallet, {});
+ // Create a new wallet in each iteration
+ // otherwise the TPS go down
+ // my assumption is that the in-memory db file gets too large
+ if (i % restartWallet == 0) {
+ if (Object.keys(wallet).length !== 0) {
+ wallet.stop();
+ }
+ wallet = await getDefaultNodeWallet({
+ // No persistent DB storage.
+ persistentStoragePath: undefined,
+ httpLib: myHttpLib,
+ });
+ await wallet.client.call(WalletApiOperation.InitWallet, {});
+ }
+
+ logger.trace(`Starting withdrawal amount=${withdrawAmount}`);
+ let start = Date.now();
await wallet.client.call(WalletApiOperation.WithdrawFakebank, {
- amount: "TESTKUDOS:10",
+ amount: b1conf.currency + ":" + withdrawAmount,
bank: b1conf.bank,
exchange: b1conf.exchange,
});
@@ -62,16 +86,24 @@ 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 amount=${withdrawAmount} time=${Date.now() - start}`);
- await wallet.runTaskLoop({
- stopWhenDone: true,
- });
+ for (let i = 0; i < numDeposits; i++) {
+
+ logger.trace(`Starting deposit amount=10`);
+ start = Date.now()
- wallet.stop();
+ await wallet.client.call(WalletApiOperation.CreateDepositGroup, {
+ amount: b1conf.currency + ":10",
+ depositPaytoUri: b1conf.payto,
+ });
+
+ await wallet.runTaskLoop({
+ stopWhenDone: true,
+ });
+
+ logger.info(`Finished deposit amount=10 time=${Date.now() - start}`);
+ }
}
}
@@ -85,6 +117,11 @@ interface Bench1Config {
bank: string;
/**
+ * Payto url for deposits.
+ */
+ payto: string;
+
+ /**
* Base URL of the exchange.
*/
exchange: string;
@@ -94,6 +131,16 @@ interface Bench1Config {
* Defaults to 1.
*/
iterations?: number;
+
+ currency: string;
+
+ deposits?: number;
+
+ /**
+ * How any iterations run until the wallet db gets purged
+ * Defaults to 20.
+ */
+ restartAfter?: number;
}
/**
@@ -102,6 +149,10 @@ 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())
+ .property("restartAfter", codecOptional(codecForNumber()))
.build("Bench1Config");