Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/naptha/tesseract.js.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'examples/browser/benchmark.html')
-rw-r--r--examples/browser/benchmark.html33
1 files changed, 33 insertions, 0 deletions
diff --git a/examples/browser/benchmark.html b/examples/browser/benchmark.html
new file mode 100644
index 0000000..d5582af
--- /dev/null
+++ b/examples/browser/benchmark.html
@@ -0,0 +1,33 @@
+<html>
+ <head>
+ <script src="/dist/tesseract.dev.js"></script>
+ </head>
+ <body>
+ <textarea id="message">Working...</textarea>
+
+ <script>
+ const { createWorker } = Tesseract;
+ const worker = createWorker();
+ (async () => {
+ await worker.load();
+ await worker.loadLanguage('eng');
+ await worker.initialize('eng');
+
+ const fileArr = ["../data/meditations.jpg", "../data/tyger.jpg", "../data/testocr.png"];
+ let timeTotal = 0;
+ for (let file of fileArr) {
+ let time1 = Date.now();
+ for (let i=0; i < 10; i++) {
+ await worker.recognize(file);
+ }
+ let time2 = Date.now();
+ const timeDif = (time2 - time1) / 1e3;
+ timeTotal += timeDif;
+ document.getElementById('message').innerHTML += "\n" + file + " [x10] runtime: " + timeDif + "s";
+ }
+ document.getElementById('message').innerHTML += "\nTotal runtime: " + timeTotal + "s";
+
+ })();
+ </script>
+ </body>
+</html>