Merge benchmark implementation for Grid5000
This commit is contained in:
commit
525fcc48dc
@ -22,11 +22,13 @@ import {
|
|||||||
codecForNumber,
|
codecForNumber,
|
||||||
codecForString,
|
codecForString,
|
||||||
codecOptional,
|
codecOptional,
|
||||||
|
Logger,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
getDefaultNodeWallet,
|
getDefaultNodeWallet,
|
||||||
NodeHttpLib,
|
NodeHttpLib,
|
||||||
WalletApiOperation,
|
WalletApiOperation,
|
||||||
|
Wallet,
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
} from "@gnu-taler/taler-wallet-core";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,6 +38,9 @@ import {
|
|||||||
* set up its own services.
|
* set up its own services.
|
||||||
*/
|
*/
|
||||||
export async function runBench1(configJson: any): Promise<void> {
|
export async function runBench1(configJson: any): Promise<void> {
|
||||||
|
|
||||||
|
const logger = new Logger("Bench1");
|
||||||
|
|
||||||
// Validate the configuration file for this benchmark.
|
// Validate the configuration file for this benchmark.
|
||||||
const b1conf = codecForBench1Config().decode(configJson);
|
const b1conf = codecForBench1Config().decode(configJson);
|
||||||
|
|
||||||
@ -43,17 +48,36 @@ export async function runBench1(configJson: any): Promise<void> {
|
|||||||
myHttpLib.setThrottling(false);
|
myHttpLib.setThrottling(false);
|
||||||
|
|
||||||
const numIter = b1conf.iterations ?? 1;
|
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++) {
|
for (let i = 0; i < numIter; i++) {
|
||||||
const wallet = await getDefaultNodeWallet({
|
// Create a new wallet in each iteration
|
||||||
// No persistent DB storage.
|
// otherwise the TPS go down
|
||||||
persistentStoragePath: undefined,
|
// my assumption is that the in-memory db file gets too large
|
||||||
httpLib: myHttpLib,
|
if (i % restartWallet == 0) {
|
||||||
});
|
if (Object.keys(wallet).length !== 0) {
|
||||||
await wallet.client.call(WalletApiOperation.InitWallet, {});
|
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, {
|
await wallet.client.call(WalletApiOperation.WithdrawFakebank, {
|
||||||
amount: "TESTKUDOS:10",
|
amount: b1conf.currency + ":" + withdrawAmount,
|
||||||
bank: b1conf.bank,
|
bank: b1conf.bank,
|
||||||
exchange: b1conf.exchange,
|
exchange: b1conf.exchange,
|
||||||
});
|
});
|
||||||
@ -62,16 +86,24 @@ export async function runBench1(configJson: any): Promise<void> {
|
|||||||
stopWhenDone: true,
|
stopWhenDone: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
await wallet.client.call(WalletApiOperation.CreateDepositGroup, {
|
logger.info(`Finished withdrawal amount=${withdrawAmount} time=${Date.now() - start}`);
|
||||||
amount: "TESTKUDOS:5",
|
|
||||||
depositPaytoUri: "payto://x-taler-bank/localhost/foo",
|
|
||||||
});
|
|
||||||
|
|
||||||
await wallet.runTaskLoop({
|
for (let i = 0; i < numDeposits; i++) {
|
||||||
stopWhenDone: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
wallet.stop();
|
logger.trace(`Starting deposit amount=10`);
|
||||||
|
start = Date.now()
|
||||||
|
|
||||||
|
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}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +116,11 @@ interface Bench1Config {
|
|||||||
*/
|
*/
|
||||||
bank: string;
|
bank: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Payto url for deposits.
|
||||||
|
*/
|
||||||
|
payto: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base URL of the exchange.
|
* Base URL of the exchange.
|
||||||
*/
|
*/
|
||||||
@ -94,6 +131,16 @@ interface Bench1Config {
|
|||||||
* Defaults to 1.
|
* Defaults to 1.
|
||||||
*/
|
*/
|
||||||
iterations?: number;
|
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 = () =>
|
const codecForBench1Config = () =>
|
||||||
buildCodecForObject<Bench1Config>()
|
buildCodecForObject<Bench1Config>()
|
||||||
.property("bank", codecForString())
|
.property("bank", codecForString())
|
||||||
|
.property("payto", codecForString())
|
||||||
.property("exchange", codecForString())
|
.property("exchange", codecForString())
|
||||||
.property("iterations", codecOptional(codecForNumber()))
|
.property("iterations", codecOptional(codecForNumber()))
|
||||||
|
.property("deposits", codecOptional(codecForNumber()))
|
||||||
|
.property("currency", codecForString())
|
||||||
|
.property("restartAfter", codecOptional(codecForNumber()))
|
||||||
.build("Bench1Config");
|
.build("Bench1Config");
|
||||||
|
Loading…
Reference in New Issue
Block a user