diff options
author | Li Jin <dragon-fly@qq.com> | 2022-11-11 09:29:01 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2022-11-11 09:29:01 +0800 |
commit | 209fca096b0be5c47553f4c4a94d95de33b23d31 (patch) | |
tree | c170264dbab9c6bb2f076de17ca171782664872a /src/yue.cpp | |
parent | e02780668e0ce2ebf7088bad2e70ad94b6824b08 (diff) | |
download | yuescript-209fca096b0be5c47553f4c4a94d95de33b23d31.tar.gz yuescript-209fca096b0be5c47553f4c4a94d95de33b23d31.tar.bz2 yuescript-209fca096b0be5c47553f4c4a94d95de33b23d31.zip |
refactor parser to be a little faster.
Diffstat (limited to 'src/yue.cpp')
-rw-r--r-- | src/yue.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/yue.cpp b/src/yue.cpp index f25c702..5b4dccc 100644 --- a/src/yue.cpp +++ b/src/yue.cpp | |||
@@ -9,7 +9,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI | |||
9 | #include "yuescript/yue_compiler.h" | 9 | #include "yuescript/yue_compiler.h" |
10 | #include "yuescript/yue_parser.h" | 10 | #include "yuescript/yue_parser.h" |
11 | 11 | ||
12 | #include <chrono> | ||
13 | #include <cstdlib> | 12 | #include <cstdlib> |
14 | #include <fstream> | 13 | #include <fstream> |
15 | #include <future> | 14 | #include <future> |
@@ -472,19 +471,13 @@ int main(int narg, const char** args) { | |||
472 | } | 471 | } |
473 | } | 472 | } |
474 | if (dumpCompileTime) { | 473 | if (dumpCompileTime) { |
475 | auto start = std::chrono::high_resolution_clock::now(); | 474 | conf.profiling = true; |
476 | auto result = yue::YueCompiler{YUE_ARGS}.compile(s, conf); | 475 | auto result = yue::YueCompiler{YUE_ARGS}.compile(s, conf); |
477 | auto end = std::chrono::high_resolution_clock::now(); | ||
478 | if (!result.codes.empty()) { | 476 | if (!result.codes.empty()) { |
479 | std::chrono::duration<double> diff = end - start; | ||
480 | start = std::chrono::high_resolution_clock::now(); | ||
481 | yue::YueParser{}.parse<yue::File_t>(s); | ||
482 | end = std::chrono::high_resolution_clock::now(); | ||
483 | std::chrono::duration<double> parseDiff = end - start; | ||
484 | std::ostringstream buf; | 477 | std::ostringstream buf; |
485 | buf << file.first << " \n"sv; | 478 | buf << file.first << " \n"sv; |
486 | buf << "Parse time: "sv << std::setprecision(5) << parseDiff.count() * 1000 << " ms\n"; | 479 | buf << "Parse time: "sv << std::setprecision(5) << result.parseTime * 1000 << " ms\n"; |
487 | buf << "Compile time: "sv << std::setprecision(5) << (diff.count() - parseDiff.count()) * 1000 << " ms\n\n"; | 480 | buf << "Compile time: "sv << std::setprecision(5) << result.compileTime * 1000 << " ms\n\n"; |
488 | return std::tuple{0, file.first, buf.str()}; | 481 | return std::tuple{0, file.first, buf.str()}; |
489 | } else { | 482 | } else { |
490 | std::ostringstream buf; | 483 | std::ostringstream buf; |