]> git.kaiwu.me - quickjs.git/commitdiff
fix microbench when microbench.txt is missing (#246)
authorCharlie Gordon <github@chqrlie.org>
Sun, 3 Mar 2024 02:38:49 +0000 (03:38 +0100)
committerGitHub <noreply@github.com>
Sun, 3 Mar 2024 02:38:49 +0000 (03:38 +0100)
tests/microbench.js

index b70e3fb5560f7bf2bbb0e19773937ff72b2a0a4e..c25e4d16e328cf6dfcd154c4bae76350f653d600 100644 (file)
@@ -1134,11 +1134,12 @@ function load_result(filename)
     if (typeof std !== "undefined") {
         // read the file in QuickJS
         var f = std.open(filename, "r");
-        if (!f) {
+        if (f) {
+            str = f.readAsString();
+            f.close();
+        } else {
             has_error = true;
         }
-        str = f.readAsString();
-        f.close();
     } else {
         return null;
     }