aboutsummaryrefslogtreecommitdiff
path: root/test/reading
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-06-30 17:31:46 +0200
committerlonkaars <loek@pipeframe.xyz>2023-06-30 17:31:46 +0200
commit722127ef4059020876f708b1d5406c04fd07b0da (patch)
tree1a849e4c8eae688a9e51aaaaaff76d56ca79f171 /test/reading
parentcc5689eaf4f7cfa158e31107906434da9aed62bf (diff)
WIP user api
Diffstat (limited to 'test/reading')
-rw-r--r--test/reading/test.ts24
1 files changed, 13 insertions, 11 deletions
diff --git a/test/reading/test.ts b/test/reading/test.ts
index 9caf890..051cfc6 100644
--- a/test/reading/test.ts
+++ b/test/reading/test.ts
@@ -1,12 +1,11 @@
import * as path from 'https://deno.land/std@0.102.0/path/mod.ts';
-Deno.chdir(path.dirname(path.fromFileUrl(Deno.mainModule)) + "/../..");
import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
-import YomikunDirectAPIClient from "../../core/direct/client.ts";
+import DirectCoreClient from '../../core/direct/client.ts';
-var api = new YomikunDirectAPIClient();
-await api.prepare();
+var core = new DirectCoreClient();
+await core.ready;
interface Test {
test: {
@@ -20,14 +19,17 @@ interface Test {
const here = path.dirname(path.fromFileUrl(import.meta.url));
const tests = JSON.parse(await Deno.readTextFile(path.resolve(here, 'cases.json'))) as Test[];
-console.log(`amount of sentences: ${tests.length}`);
-console.log(`average sentence length: ${tests.map(t => t.test.input.length).reduce((a, b) => a + b) / tests.length}`);
-
-console.time("parse");
+var timeStart = performance.now();
for (var { test } of tests) {
- var result = await api.parseSentence(test.input);
+ var result = await core.parseSentence(test.input);
// TODO: add reading back into conjugated verb to complete this test
-
}
-console.timeEnd("parse");
+var timeEnd = performance.now();
+var duration = timeEnd - timeStart;
+var averageLength = tests.map(t => t.test.input.length).reduce((a, b) => a + b) / tests.length;
+
+console.log(` amount of sentences: ${tests.length}`);
+console.log(`average sentence length: ${averageLength.toFixed(1)} characters`);
+console.log(` test duration: ${duration.toFixed(0)} ms`);
+console.log(` average throughput: ${(tests.length / (duration / 1e3)).toFixed(1)} sentence/second`);