From b3cd21fec72a14a3229f147b40c03a47b0f970f0 Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Tue, 18 Jun 2024 00:11:27 +0900 Subject: [PATCH] Enhance benchmark cli options --- test/benchmark/index.ts | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/test/benchmark/index.ts b/test/benchmark/index.ts index 31ed3d9..bae1bfb 100644 --- a/test/benchmark/index.ts +++ b/test/benchmark/index.ts @@ -1,15 +1,18 @@ -import { DynamicBenchmarker } from "@nestia/e2e"; +import { DynamicBenchmarker, StopWatch } from "@nestia/e2e"; import fs from "fs"; import os from "os"; import { MyBackend } from "../../src/MyBackend"; import { MyConfiguration } from "../../src/MyConfiguration"; import { MyGlobal } from "../../src/MyGlobal"; +import { MySetupWizard } from "../../src/setup/MySetupWizard"; import { ArgumentParser } from "../../src/utils/ArgumentParser"; interface IOptions { + reset: boolean; include?: string[]; exclude?: string[]; + trace: boolean; count: number; threads: number; simultaneous: number; @@ -17,8 +20,8 @@ interface IOptions { const getOptions = () => ArgumentParser.parse(async (command, prompt, action) => { - // command.option("--mode ", "target mode"); - // command.option("--reset ", "reset local DB or not"); + command.option("--mode ", "target mode"); + command.option("--reset ", "reset local DB or not"); command.option("--include ", "include feature files"); command.option("--exclude ", "exclude feature files"); command.option("--count ", "number of requests to make"); @@ -28,14 +31,10 @@ const getOptions = () => "number of simultaneous requests to make", ); return action(async (options) => { - // if (typeof options.reset === "string") - // options.reset = options.reset === "true"; - // options.mode ??= await prompt.select("mode")("Select mode")([ - // "LOCAL", - // "DEV", - // "REAL", - // ]); - // options.reset ??= await prompt.boolean("reset")("Reset local DB"); + if (typeof options.reset === "string") + options.reset = options.reset === "true"; + options.reset ??= await prompt.boolean("reset")("Reset local DB"); + options.trace = options.trace !== ("false" as any); options.count = Number( options.count ?? (await prompt.number("count")("Number of requests to make")), @@ -59,6 +58,11 @@ const main = async (): Promise => { const options: IOptions = await getOptions(); MyGlobal.testing = true; + if (options.reset) { + await StopWatch.trace("Reset DB")(MySetupWizard.schema); + await StopWatch.trace("Seed Data")(MySetupWizard.seed); + } + // BACKEND SERVER const backend: MyBackend = new MyBackend(); await backend.open();