• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

programming language


Commit MetaInfo

Revisión0d76f7e19ef7c9b6dc693fc4e07770d06d5336c1 (tree)
Tiempo2022-04-10 21:08:36
Autordhrname <dhrname@joes...>
Commiterdhrname

Log Message

Add the time clock for the Parser::parse method

Cambiar Resumen

Diferencia incremental

Binary files a/bin/obj/main.o and b/bin/obj/main.o differ
--- a/main.cpp
+++ b/main.cpp
@@ -30,6 +30,7 @@
3030 #include <vector>
3131 #include <iterator>
3232 #include <unordered_map>
33+#include <chrono>
3334 #include "include/node.hpp"
3435 #include "include/FlexLexer.h"
3536 #include "llvm/ADT/APFloat.h"
@@ -2045,7 +2046,6 @@ namespace jstr
20452046 * 句ノードの位置座標を割り振っていく*/
20462047 void setCoordinate(Node* phrlist)
20472048 {
2048-
20492049 while ( phrlist->isNode() )
20502050 {
20512051 if ( phrlist->isCaseOf(typeid(Phrase*)) )
@@ -2058,7 +2058,12 @@ namespace jstr
20582058 for (int32_t i = 0;i<BNF_NONTERMINAL_LENGTH;i++)
20592059 {
20602060 int32_t id = bnf[i][j][k];
2061- if (id == p->tokenId)
2061+ if (id <= 0)
2062+ {
2063+ /*bnfを疎な配列と見なして最適化*/
2064+ break;
2065+ }
2066+ else if (id == p->tokenId)
20622067 {
20632068 p->setCoordinate(i, j, k);
20642069 }
@@ -2089,6 +2094,9 @@ namespace jstr
20892094 * 0ならば、ファイルストリーム読み込みが終了したことを示す*/
20902095 int ret;
20912096
2097+ using namespace std::chrono;
2098+ auto t = system_clock::now();
2099+
20922100 /*currentPhr 変数
20932101 * 現在の句ノード*/
20942102 Phrase* currentPhr = nullptr;
@@ -2100,6 +2108,8 @@ namespace jstr
21002108 while ((ret = lexer->yylex()) != 0)
21012109 {
21022110 Phrase* phr = createPhrase(ret);
2111+ /*次の一文を書き換えると、メモリ解放ができなくなる
2112+ * phrlistがガベージコレクションのパンくずリストの役割を果たす*/
21032113 phrlist->appendChild(phrlist->makeNode(phr));
21042114
21052115 switch (ret)
@@ -2434,6 +2444,10 @@ namespace jstr
24342444 ifs.close();
24352445 delete lexer;
24362446 lexer = nullptr;
2447+
2448+ auto d = system_clock::now()-t;
2449+ std::cout << "something took " << duration_cast<milliseconds>(d).count() << "ms" << std::endl;
2450+
24372451 }
24382452
24392453