From 4407c06f12ff1176313dedace3d900b3b8436e9e Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 16 May 2025 17:05:59 +0200 Subject: [PATCH] lib/cli: add timing logs to query commands --- lib/cli/commands/query_kanji.dart | 4 ++++ lib/cli/commands/query_word.dart | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/cli/commands/query_kanji.dart b/lib/cli/commands/query_kanji.dart index c5be8bd..b1cf3c2 100644 --- a/lib/cli/commands/query_kanji.dart +++ b/lib/cli/commands/query_kanji.dart @@ -29,12 +29,16 @@ class QueryKanji extends Command { libsqlitePath: argResults!.option('libsqlite')!, ); + final time = Stopwatch()..start(); final result = await JaDBConnection(db).searchKanji('漢'); + time.stop(); if (result == null) { print("No such kanji"); } else { print(JsonEncoder.withIndent(' ').convert(result.toJson())); } + + print("Query took ${time.elapsedMilliseconds}ms"); } } diff --git a/lib/cli/commands/query_word.dart b/lib/cli/commands/query_word.dart index 9054ace..b5a39b1 100644 --- a/lib/cli/commands/query_word.dart +++ b/lib/cli/commands/query_word.dart @@ -29,7 +29,9 @@ class QueryWord extends Command { libsqlitePath: argResults!.option('libsqlite')!, ); + final time = Stopwatch()..start(); final result = await JaDBConnection(db).searchWord('かな'); + time.stop(); if (result == null) { print("Invalid search"); @@ -39,5 +41,7 @@ class QueryWord extends Command { print(JsonEncoder.withIndent(' ') .convert(result.map((e) => e.toJson()).toList())); } + + print("Query took ${time.elapsedMilliseconds}ms"); } }