lib/cli: add timing logs to query commands

This commit is contained in:
2025-05-16 17:05:59 +02:00
parent fc0956d5c3
commit 4407c06f12
2 changed files with 8 additions and 0 deletions

View File

@@ -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");
}
}

View File

@@ -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");
}
}