From 087d1b20a6ff0d1fc43c3ed921ad8936959aa934 Mon Sep 17 00:00:00 2001 From: saqut Date: Thu, 18 Jun 2026 18:35:10 +0300 Subject: [PATCH] perf(tokenizer): switch dispatch + unordered_map keyword lookup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Önceki: for döngüsü içinde her token için include() 63 kez çağrılıyordu → 66.9M include() çağrısı, zamanın %81'i Sonraki: - Operatör/delimiter: switch(c0) + getchar(1) ile O(1) dispatch - Keyword: readIdentifier() → unordered_map::find() O(1) lookup - include() yalnızca // /* */ için (2-3 çağrı/yorum satırı) Sonuç (2.3MB, 90K satır, debug build): tokens: 11.5s → 2.4s (−79%) check: 12.7s → 3.7s (−71%) gprof ÖNCE: %81 include() (66.9M çağrı) gprof SONRA: include() %0.00 — artık ölçülemez Profil dosyaları: docs/perf-before.txt, docs/perf-after.txt --- build/.ninja_deps | Bin 90976 -> 67224 bytes build/.ninja_log | 70 +++--- docs/perf-after.txt | 421 ++++++++++++++++++++++++++++++++++++ docs/perf-before.txt | 406 ++++++++++++++++++++++++++++++++++ src/tokenizer/tokenizer.cpp | 230 ++++++++++++++++---- 5 files changed, 1036 insertions(+), 91 deletions(-) create mode 100644 docs/perf-after.txt create mode 100644 docs/perf-before.txt diff --git a/build/.ninja_deps b/build/.ninja_deps index d8521216db6ead4e416dba335979f422c4958ae0..5ac856e83c2720052d3f847eb0c1ae1eba32dbe6 100644 GIT binary patch delta 558 zcmaEGjCDpY%Z3AP+f8^GD_A#M_((8r_lad}VBLHnsDNer79qwRtdoDlT-h!n$2fy^ z@`OyS$$iOL+e0)Vycyd|BtWbK`4hH((SxaY7s@?Zwk&@87G;=-T}|G06Dt@muPJZ) z6cZqCb4f=E+x9E=j3R8C-%Rmfo_-~Xv1js?c>$t+|Nj49!OGAupOJxq;RvtlHj`Zv z8#h1vI-7O!l_egczCh^{K}G%3f$}CW8>QcbVM>xQE8s*Z;&}cjGI{bT7ZJ_K*69cIkxp?o4bBju}&}W zX5`@1U-n&Ky%{jHwl{h+E@tIyWqxE0;zNRG`UN(intW!qG>{lLJodA)Szl)_S#LId gUkqa(Tac#So}Eww&m;kz^8b0@>78bi`}VW}0OMiV%>V!Z delta 827 zcmYk4Z%9*77{;&WIk?2hK8VBqAW9~Z&P1Vt`cN?ybV!!cA2C@(j=bHRS;=i)S7Zp@ zNylJdsG&h!1>N47&B7#Yj6l#3Ga_*af<&SaBu3hM-JSI1<(%Jhp8G!MJ=fh9vk)Ld zV`iHFDb6IDAYg8#v?O`7pxp%7%Z&u4&ImEoGJaQgD+l;RFJbGKW(;$u@_SvT5o3K6 z$3=4-cO9w)4`H&^Mr(shS6wF9v}RJ;=3iUEb+#>)((|vFg6nc2of_7RAJW>K|R9)Daq%AQ$H4avi<>b3le% zcFg^d<;dAAvn|PJ6$H!X*46~!q-W?Z{kE6|xg$mo9NrivY|LGnSc38kl)F)8eP6e{ zD0{)b(us0cVPY}LL6mz?URtY5QQZLhy5AB*#5GxD_rKO$y+rps_3{^W8$P8sQciNB zxoWrF;!}g_slJ`#q)ucBzq_h^+kxXn>~Rs%7r_8Y`M zMJ6JP`4u{@Kyw2l+sJ`v`u@0C0gtGmMnnaj2Q3Pm6EtK;RGHCHroeQih9pF-Kllp@ zgq#{`K;$jc)hO`Ss-ZiGk_QHx6v(n6id@N&-uPL8?{Wg&nZ>TSnOP+-GC}e#)+j*#4;uCr8}J;kEZSSshyof$4$f^@M+=jq1NlhPpjMi f0*Ha4n<~-*oDD8Gd}@FvVpJ@YmPmvha(Da#Eb2v! diff --git a/build/.ninja_log b/build/.ninja_log index 3d326c6..9a14d03 100644 --- a/build/.ninja_log +++ b/build/.ninja_log @@ -1,55 +1,37 @@ # ninja log v7 1 6106 1781788886608927872 CMakeFiles/saqut.dir/src/core/sourcefile.cpp.o da6f5fc90e87e6b1 -1 3694 1781788886610186419 CMakeFiles/saqut.dir/src/lexer/lexer.cpp.o 90eeec811f2137e6 -8929 12696 1781788895536938159 CMakeFiles/saqut.dir/src/tokenizer/tokenizer.cpp.o a01677f8bb4f4dbc -1 2516 1781789879291876730 CMakeFiles/saqut.dir/src/parser/parser.cpp.o 2c65b7be26cead32 -3 9947 1781788886611876031 CMakeFiles/saqut.dir/src/parser/nodes/program.cpp.o ac5bbcd74d87561a -3 8929 1781788886610927874 CMakeFiles/saqut.dir/src/parser/nodes/identifier.cpp.o eb96bb4b1eb4ad80 -2 11212 1781788886610587227 CMakeFiles/saqut.dir/src/parser/nodes/expressions.cpp.o 4057e3d63c63a1ab -3 10066 1781788886611770636 CMakeFiles/saqut.dir/src/parser/nodes/literal.cpp.o 78f2c4da7c9b2281 -7 12109 1781788886614927879 CMakeFiles/saqut.dir/src/parser/nodes/statements.cpp.o b5c20724bbf3648c -1 10950 1781788886610366872 CMakeFiles/saqut.dir/src/parser/nodes/binary_expr.cpp.o d2e2bb2f8a63c6d2 -1 11244 1781788886610473997 CMakeFiles/saqut.dir/src/parser/nodes/declarations.cpp.o b6c56f04a257f685 -1 5243 1781792343880679446 CMakeFiles/saqut.dir/src/main.cpp.o 110c26cb1d0c3a23 -5243 5478 1781792349122684689 saqut 77cf84e33c34ab02 -0 22 1781792352391905736 build.ninja 1876a59d627a585 -0 22 1781792352391378326 /home/saqut/Masaüstü/saqutcompiler/build/cmake_install.cmake 1876a59d627a585 -1 3851 1781792343882099316 CMakeFiles/saqut.dir/src/symbol/symbol_collector.cpp.o 3348f498f369213d -1 3077 1781792343881863451 CMakeFiles/saqut.dir/src/semantic/structural_validator.cpp.o 4bfec8abc0e9893e -1 3624 1781792343881974165 CMakeFiles/saqut.dir/src/semantic/type_checker.cpp.o 15f44776b9c3e26d -1 3032 1781792355630982632 CMakeFiles/saqut.dir/src/semantic/structural_validator.cpp.o 4bfec8abc0e9893e -1 3534 1781792355631085471 CMakeFiles/saqut.dir/src/semantic/type_checker.cpp.o 15f44776b9c3e26d -1 5538 1781792355629691194 CMakeFiles/saqut.dir/src/main.cpp.o 110c26cb1d0c3a23 -5538 5861 1781792361166696724 saqut 77cf84e33c34ab02 -1 4565 1781794501587748975 CMakeFiles/saqut.dir/src/lexer/lexer.cpp.o 90eeec811f2137e6 -6 5765 1781794501593748981 CMakeFiles/saqut.dir/src/parser/parser.cpp.o 2c65b7be26cead32 -2 6786 1781794501590384636 CMakeFiles/saqut.dir/src/parser/nodes/statements.cpp.o b5c20724bbf3648c -2 6934 1781794501589760926 CMakeFiles/saqut.dir/src/parser/nodes/binary_expr.cpp.o d2e2bb2f8a63c6d2 -2 7059 1781794501590181179 CMakeFiles/saqut.dir/src/parser/nodes/literal.cpp.o 78f2c4da7c9b2281 -2 7150 1781794501590288617 CMakeFiles/saqut.dir/src/parser/nodes/program.cpp.o ac5bbcd74d87561a -2 7264 1781794501589877089 CMakeFiles/saqut.dir/src/parser/nodes/declarations.cpp.o b6c56f04a257f685 -2 7510 1781794501590069464 CMakeFiles/saqut.dir/src/parser/nodes/identifier.cpp.o eb96bb4b1eb4ad80 -2 7889 1781794501589962656 CMakeFiles/saqut.dir/src/parser/nodes/expressions.cpp.o 4057e3d63c63a1ab -2 9281 1781794501588748976 CMakeFiles/saqut.dir/src/main.cpp.o 110c26cb1d0c3a23 -4565 9347 1781794506151753299 CMakeFiles/saqut.dir/src/semantic/structural_validator.cpp.o 4bfec8abc0e9893e -6934 9664 1781794508520755543 CMakeFiles/saqut.dir/src/tokenizer/tokenizer.cpp.o a01677f8bb4f4dbc -5765 9917 1781794507351754435 CMakeFiles/saqut.dir/src/semantic/type_checker.cpp.o 15f44776b9c3e26d -6786 10724 1781794508372755403 CMakeFiles/saqut.dir/src/symbol/symbol_collector.cpp.o 3348f498f369213d -10724 10943 1781794512310759133 saqut 77cf84e33c34ab02 1 5577 1781794548935793844 CMakeFiles/saqut.dir/src/lexer/lexer.cpp.o 90eeec811f2137e6 +2 1784 1781794795003026937 CMakeFiles/saqut.dir/src/tokenizer/tokenizer.cpp.o a01677f8bb4f4dbc 6 7118 1781794548940793848 CMakeFiles/saqut.dir/src/parser/parser.cpp.o 2c65b7be26cead32 -1 7401 1781794548937164958 CMakeFiles/saqut.dir/src/parser/nodes/expressions.cpp.o 4057e3d63c63a1ab 1 7781 1781794548937485082 CMakeFiles/saqut.dir/src/parser/nodes/program.cpp.o ac5bbcd74d87561a -5 7795 1781794548939793847 CMakeFiles/saqut.dir/src/parser/nodes/statements.cpp.o b5c20724bbf3648c 1 7846 1781794548937277813 CMakeFiles/saqut.dir/src/parser/nodes/identifier.cpp.o eb96bb4b1eb4ad80 +1 7401 1781794548937164958 CMakeFiles/saqut.dir/src/parser/nodes/expressions.cpp.o 4057e3d63c63a1ab 1 8355 1781794548937386639 CMakeFiles/saqut.dir/src/parser/nodes/literal.cpp.o 78f2c4da7c9b2281 -1 8623 1781794548937059964 CMakeFiles/saqut.dir/src/parser/nodes/declarations.cpp.o b6c56f04a257f685 +5 7795 1781794548939793847 CMakeFiles/saqut.dir/src/parser/nodes/statements.cpp.o b5c20724bbf3648c 1 8702 1781794548936968496 CMakeFiles/saqut.dir/src/parser/nodes/binary_expr.cpp.o d2e2bb2f8a63c6d2 +1 8623 1781794548937059964 CMakeFiles/saqut.dir/src/parser/nodes/declarations.cpp.o b6c56f04a257f685 1 9568 1781794548936880430 CMakeFiles/saqut.dir/src/main.cpp.o 110c26cb1d0c3a23 -7781 10439 1781794556715801213 CMakeFiles/saqut.dir/src/tokenizer/tokenizer.cpp.o a01677f8bb4f4dbc +1784 2001 1781794796785028624 saqut 77cf84e33c34ab02 +0 22 1781795949575516449 build.ninja 1876a59d627a585 +0 22 1781795949575428471 /home/saqut/Masaüstü/saqutcompiler/build/cmake_install.cmake 1876a59d627a585 +7401 11835 1781794556335800853 CMakeFiles/saqut.dir/src/symbol/symbol_collector.cpp.o 3348f498f369213d 5577 10556 1781794554511799126 CMakeFiles/saqut.dir/src/semantic/structural_validator.cpp.o 4bfec8abc0e9893e 7118 11087 1781794556053800586 CMakeFiles/saqut.dir/src/semantic/type_checker.cpp.o 15f44776b9c3e26d -7401 11835 1781794556335800853 CMakeFiles/saqut.dir/src/symbol/symbol_collector.cpp.o 3348f498f369213d -11836 12067 1781794560770805055 saqut 77cf84e33c34ab02 -2 1784 1781794795003026937 CMakeFiles/saqut.dir/src/tokenizer/tokenizer.cpp.o a01677f8bb4f4dbc -1784 2001 1781794796785028624 saqut 77cf84e33c34ab02 +13 4576 1781796718440262330 CMakeFiles/saqut.dir/src/core/sourcefile.cpp.o 20f68631dd335029 +13 4805 1781796718441539505 CMakeFiles/saqut.dir/src/lexer/lexer.cpp.o 5fd259c0401f3e22 +16 6700 1781796718443848488 CMakeFiles/saqut.dir/src/parser/nodes/identifier.cpp.o e3b5b38d75fcd2ca +15 6733 1781796718442847556 CMakeFiles/saqut.dir/src/parser/nodes/declarations.cpp.o c3d262615ede4c95 +14 6864 1781796718442362341 CMakeFiles/saqut.dir/src/parser/nodes/binary_expr.cpp.o 5cc8b697133bcf64 +21 6876 1781796718448262357 CMakeFiles/saqut.dir/src/parser/nodes/program.cpp.o 9313cba8d8daffed +21 7502 1781796718449424977 CMakeFiles/saqut.dir/src/parser/nodes/statements.cpp.o 3c8869307381c930 +16 7589 1781796718444498682 CMakeFiles/saqut.dir/src/parser/nodes/literal.cpp.o 55743f37408c5f +15 7814 1781796718443331391 CMakeFiles/saqut.dir/src/parser/nodes/expressions.cpp.o 5f5bb01381a3c3ad +14 8751 1781796718441949529 CMakeFiles/saqut.dir/src/main.cpp.o 3cfef7a665d5bf87 +4580 9322 1781796723007277591 CMakeFiles/saqut.dir/src/parser/parser.cpp.o 59cdb5935c541b26 +6864 9502 1781796725291285201 CMakeFiles/saqut.dir/src/tokenizer/tokenizer.cpp.o fbabe80dcb141239 +4805 9685 1781796723232278341 CMakeFiles/saqut.dir/src/semantic/structural_validator.cpp.o 248faa3675024351 +6700 10405 1781796725127284655 CMakeFiles/saqut.dir/src/semantic/type_checker.cpp.o b29c133293d988b0 +6733 11112 1781796725160284765 CMakeFiles/saqut.dir/src/symbol/symbol_collector.cpp.o ec4e483b8ddb4007 +11112 11349 1781796729539299317 saqut a8f6b7bef23ca761 +1 2117 1781796771817437208 CMakeFiles/saqut.dir/src/tokenizer/tokenizer.cpp.o fbabe80dcb141239 +2117 2374 1781796773933443989 saqut a8f6b7bef23ca761 diff --git a/docs/perf-after.txt b/docs/perf-after.txt new file mode 100644 index 0000000..e99e2bf --- /dev/null +++ b/docs/perf-after.txt @@ -0,0 +1,421 @@ +Flat profile: + +Each sample counts as 0.01 seconds. + % cumulative self self total + time seconds seconds calls ms/call ms/call name + 22.22 0.02 0.02 1064503 0.00 0.00 SourceFile::offsetToLocation(int) const + 11.11 0.03 0.01 1059636 0.00 0.00 Tokenizer::scope() + 11.11 0.04 0.01 1059635 0.00 0.00 Lexer::isNumeric() + 11.11 0.05 0.01 461302 0.00 0.00 DelimiterToken::~DelimiterToken() + 11.11 0.06 0.01 278426 0.00 0.00 DelimiterToken::DelimiterToken() + 11.11 0.07 0.01 133847 0.00 0.00 Lexer::readNumeric() + 11.11 0.08 0.01 1 10.00 90.00 cmdTokens(CliArgs const&) + 11.11 0.09 0.01 1 10.00 70.00 Tokenizer::scan(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator >) + 0.00 0.09 0.00 2754372 0.00 0.00 Lexer::isEnd() + 0.00 0.09 0.00 2620524 0.00 0.00 Lexer::getchar() + 0.00 0.09 0.00 2119274 0.00 0.00 Lexer::include(std::basic_string_view >, bool) + 0.00 0.09 0.00 1851576 0.00 0.00 Lexer::getOffset() + 0.00 0.09 0.00 1059640 0.00 0.00 Lexer::skipWhiteSpace() + 0.00 0.09 0.00 991432 0.00 0.00 std::__detail::_Map_base, std::allocator >, std::pair, std::allocator > const, int>, std::allocator, std::allocator > const, int> >, std::__detail::_Select1st, std::equal_to, std::allocator > >, std::hash, std::allocator > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits, true>::operator[](std::__cxx11::basic_string, std::allocator > const&) + 0.00 0.09 0.00 925788 0.00 0.00 Lexer::getchar(int) + 0.00 0.09 0.00 691504 0.00 0.00 Lexer::getLocation() + 0.00 0.09 0.00 691504 0.00 0.00 Lexer::toChar(int) + 0.00 0.09 0.00 400817 0.00 0.00 Lexer::nextChar() + 0.00 0.09 0.00 234284 0.00 0.00 IdentifierToken::~IdentifierToken() + 0.00 0.09 0.00 234284 0.00 0.00 Lexer::beginPosition() + 0.00 0.09 0.00 234284 0.00 0.00 Lexer::acceptPosition() + 0.00 0.09 0.00 234284 0.00 0.00 Tokenizer::readIdentifier() + 0.00 0.09 0.00 230202 0.00 0.00 OperatorToken::OperatorToken() + 0.00 0.09 0.00 230202 0.00 0.00 OperatorToken::~OperatorToken() + 0.00 0.09 0.00 133847 0.00 0.00 NumberToken::~NumberToken() + 0.00 0.09 0.00 58981 0.00 0.00 KeywordToken::~KeywordToken() + 0.00 0.09 0.00 21 0.00 0.00 void std::__cxx11::basic_string, std::allocator >::_M_construct(char const*, unsigned long) + 0.00 0.09 0.00 20 0.00 0.00 std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) + 0.00 0.09 0.00 19 0.00 0.00 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) + 0.00 0.09 0.00 11 0.00 0.00 bool std::operator==, std::allocator >(std::__cxx11::basic_string, std::allocator > const&, char const*) + 0.00 0.09 0.00 9 0.00 0.00 CliCommand::~CliCommand() + 0.00 0.09 0.00 7 0.00 0.00 std::vector >::push_back(CliCommand const&) + 0.00 0.09 0.00 3 0.00 0.00 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) + 0.00 0.09 0.00 3 0.00 0.00 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) + 0.00 0.09 0.00 3 0.00 0.00 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) + 0.00 0.09 0.00 3 0.00 0.00 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) + 0.00 0.09 0.00 2 0.00 0.00 std::_Hashtable > >, std::allocator > > >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Hashtable > > const*>(std::pair > > const*, std::pair > > const*, unsigned long, std::hash const&, std::equal_to const&, std::allocator > > > const&, std::integral_constant) + 0.00 0.09 0.00 2 0.00 0.00 std::_Hashtable >, std::pair > const, TokenType>, std::allocator > const, TokenType> >, std::__detail::_Select1st, std::equal_to > >, std::hash > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Hashtable > const, TokenType> const*>(std::pair > const, TokenType> const*, std::pair > const, TokenType> const*, unsigned long, std::hash > > const&, std::equal_to > > const&, std::allocator > const, TokenType> > const&, std::integral_constant) + 0.00 0.09 0.00 1 0.00 0.00 readSource[abi:cxx11](CliArgs const&) + 0.00 0.09 0.00 1 0.00 0.00 parseArgs(int, char**) + 0.00 0.09 0.00 1 0.00 0.00 SourceFile::computeLineStarts() + 0.00 0.09 0.00 1 0.00 0.00 SourceFile::setText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) + 0.00 0.09 0.00 1 0.00 0.00 Lexer::setSourceText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) + 0.00 0.09 0.00 1 0.00 0.00 std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) + + % the percentage of the total running time of the +time program used by this function. + +cumulative a running sum of the number of seconds accounted + seconds for by this function and those listed above it. + + self the number of seconds accounted for by this +seconds function alone. This is the major sort for this + listing. + +calls the number of times this function was invoked, if + this function is profiled, else blank. + + self the average number of milliseconds spent in this +ms/call function per call, if this function is profiled, + else blank. + + total the average number of milliseconds spent in this +ms/call function and its descendents per call, if this + function is profiled, else blank. + +name the name of the function. This is the minor sort + for this listing. The index shows the location of + the function in the gprof listing. If the index is + in parenthesis it shows where it would appear in + the gprof listing if it were to be printed. + +Copyright (C) 2012-2026 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + + Call graph (explanation follows) + + +granularity: each sample hit covers 4 byte(s) for 11.11% of 0.09 seconds + +index % time self children called name + +[1] 100.0 0.00 0.09 main [1] + 0.01 0.08 1/1 cmdTokens(CliArgs const&) [2] + 0.00 0.00 18/20 std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) [35] + 0.00 0.00 9/9 CliCommand::~CliCommand() [38] + 0.00 0.00 7/19 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [36] + 0.00 0.00 7/7 std::vector >::push_back(CliCommand const&) [39] + 0.00 0.00 4/21 void std::__cxx11::basic_string, std::allocator >::_M_construct(char const*, unsigned long) [34] + 0.00 0.00 1/1 parseArgs(int, char**) [47] + 0.00 0.00 1/11 bool std::operator==, std::allocator >(std::__cxx11::basic_string, std::allocator > const&, char const*) [37] + 0.00 0.00 1/1 std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) [51] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [42] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [41] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [40] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [43] +----------------------------------------------- + 0.01 0.08 1/1 main [1] +[2] 100.0 0.01 0.08 1 cmdTokens(CliArgs const&) [2] + 0.01 0.06 1/1 Tokenizer::scan(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator >) [3] + 0.01 0.00 461302/461302 DelimiterToken::~DelimiterToken() [9] + 0.00 0.00 230202/230202 OperatorToken::~OperatorToken() [31] + 0.00 0.00 175303/234284 IdentifierToken::~IdentifierToken() [27] + 0.00 0.00 133847/133847 NumberToken::~NumberToken() [32] + 0.00 0.00 58981/58981 KeywordToken::~KeywordToken() [33] + 0.00 0.00 2/21 void std::__cxx11::basic_string, std::allocator >::_M_construct(char const*, unsigned long) [34] + 0.00 0.00 1/1 readSource[abi:cxx11](CliArgs const&) [46] +----------------------------------------------- + 0.01 0.06 1/1 cmdTokens(CliArgs const&) [2] +[3] 77.8 0.01 0.06 1 Tokenizer::scan(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator >) [3] + 0.01 0.05 1059636/1059636 Tokenizer::scope() [4] + 0.00 0.00 1059635/2754372 Lexer::isEnd() [18] + 0.00 0.00 1/1 Lexer::setSourceText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) [50] +----------------------------------------------- + 0.01 0.05 1059636/1059636 Tokenizer::scan(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator >) [3] +[4] 66.7 0.01 0.05 1059636 Tokenizer::scope() [4] + 0.00 0.01 691504/691504 Lexer::getLocation() [6] + 0.01 0.00 133847/133847 Lexer::readNumeric() [7] + 0.01 0.00 1059635/1059635 Lexer::isNumeric() [8] + 0.01 0.00 278426/278426 DelimiterToken::DelimiterToken() [10] + 0.00 0.00 234284/234284 Tokenizer::readIdentifier() [11] + 0.00 0.00 2119274/2119274 Lexer::include(std::basic_string_view >, bool) [20] + 0.00 0.00 1985561/2620524 Lexer::getchar() [19] + 0.00 0.00 1383008/1851576 Lexer::getOffset() [21] + 0.00 0.00 1059774/2754372 Lexer::isEnd() [18] + 0.00 0.00 1059640/1059640 Lexer::skipWhiteSpace() [22] + 0.00 0.00 991400/991432 std::__detail::_Map_base, std::allocator >, std::pair, std::allocator > const, int>, std::allocator, std::allocator > const, int> >, std::__detail::_Select1st, std::equal_to, std::allocator > >, std::hash, std::allocator > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits, true>::operator[](std::__cxx11::basic_string, std::allocator > const&) [23] + 0.00 0.00 925788/925788 Lexer::getchar(int) [24] + 0.00 0.00 691504/691504 Lexer::toChar(int) [25] + 0.00 0.00 230202/230202 OperatorToken::OperatorToken() [30] + 0.00 0.00 58981/234284 IdentifierToken::~IdentifierToken() [27] + 0.00 0.00 138/400817 Lexer::nextChar() [26] +----------------------------------------------- + 0.00 0.00 138715/1064503 Lexer::readNumeric() [7] + 0.00 0.00 234284/1064503 Tokenizer::readIdentifier() [11] + 0.01 0.00 691504/1064503 Lexer::getLocation() [6] +[5] 22.2 0.02 0.00 1064503 SourceFile::offsetToLocation(int) const [5] +----------------------------------------------- + 0.00 0.01 691504/691504 Tokenizer::scope() [4] +[6] 14.4 0.00 0.01 691504 Lexer::getLocation() [6] + 0.01 0.00 691504/1064503 SourceFile::offsetToLocation(int) const [5] +----------------------------------------------- + 0.01 0.00 133847/133847 Tokenizer::scope() [4] +[7] 14.0 0.01 0.00 133847 Lexer::readNumeric() [7] + 0.00 0.00 138715/1064503 SourceFile::offsetToLocation(int) const [5] +----------------------------------------------- + 0.01 0.00 1059635/1059635 Tokenizer::scope() [4] +[8] 11.1 0.01 0.00 1059635 Lexer::isNumeric() [8] +----------------------------------------------- + 0.01 0.00 461302/461302 cmdTokens(CliArgs const&) [2] +[9] 11.1 0.01 0.00 461302 DelimiterToken::~DelimiterToken() [9] +----------------------------------------------- + 0.01 0.00 278426/278426 Tokenizer::scope() [4] +[10] 11.1 0.01 0.00 278426 DelimiterToken::DelimiterToken() [10] +----------------------------------------------- + 0.00 0.00 234284/234284 Tokenizer::scope() [4] +[11] 4.9 0.00 0.00 234284 Tokenizer::readIdentifier() [11] + 0.00 0.00 234284/1064503 SourceFile::offsetToLocation(int) const [5] + 0.00 0.00 634963/2754372 Lexer::isEnd() [18] + 0.00 0.00 634963/2620524 Lexer::getchar() [19] + 0.00 0.00 468568/1851576 Lexer::getOffset() [21] + 0.00 0.00 400679/400817 Lexer::nextChar() [26] + 0.00 0.00 234284/234284 Lexer::beginPosition() [28] + 0.00 0.00 234284/234284 Lexer::acceptPosition() [29] +----------------------------------------------- + 0.00 0.00 634963/2754372 Tokenizer::readIdentifier() [11] + 0.00 0.00 1059635/2754372 Tokenizer::scan(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator >) [3] + 0.00 0.00 1059774/2754372 Tokenizer::scope() [4] +[18] 0.0 0.00 0.00 2754372 Lexer::isEnd() [18] +----------------------------------------------- + 0.00 0.00 634963/2620524 Tokenizer::readIdentifier() [11] + 0.00 0.00 1985561/2620524 Tokenizer::scope() [4] +[19] 0.0 0.00 0.00 2620524 Lexer::getchar() [19] +----------------------------------------------- + 0.00 0.00 2119274/2119274 Tokenizer::scope() [4] +[20] 0.0 0.00 0.00 2119274 Lexer::include(std::basic_string_view >, bool) [20] +----------------------------------------------- + 0.00 0.00 468568/1851576 Tokenizer::readIdentifier() [11] + 0.00 0.00 1383008/1851576 Tokenizer::scope() [4] +[21] 0.0 0.00 0.00 1851576 Lexer::getOffset() [21] +----------------------------------------------- + 0.00 0.00 1059640/1059640 Tokenizer::scope() [4] +[22] 0.0 0.00 0.00 1059640 Lexer::skipWhiteSpace() [22] +----------------------------------------------- + 0.00 0.00 32/991432 __static_initialization_and_destruction_0() [81] + 0.00 0.00 991400/991432 Tokenizer::scope() [4] +[23] 0.0 0.00 0.00 991432 std::__detail::_Map_base, std::allocator >, std::pair, std::allocator > const, int>, std::allocator, std::allocator > const, int> >, std::__detail::_Select1st, std::equal_to, std::allocator > >, std::hash, std::allocator > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits, true>::operator[](std::__cxx11::basic_string, std::allocator > const&) [23] +----------------------------------------------- + 0.00 0.00 925788/925788 Tokenizer::scope() [4] +[24] 0.0 0.00 0.00 925788 Lexer::getchar(int) [24] +----------------------------------------------- + 0.00 0.00 691504/691504 Tokenizer::scope() [4] +[25] 0.0 0.00 0.00 691504 Lexer::toChar(int) [25] +----------------------------------------------- + 0.00 0.00 138/400817 Tokenizer::scope() [4] + 0.00 0.00 400679/400817 Tokenizer::readIdentifier() [11] +[26] 0.0 0.00 0.00 400817 Lexer::nextChar() [26] +----------------------------------------------- + 0.00 0.00 58981/234284 Tokenizer::scope() [4] + 0.00 0.00 175303/234284 cmdTokens(CliArgs const&) [2] +[27] 0.0 0.00 0.00 234284 IdentifierToken::~IdentifierToken() [27] +----------------------------------------------- + 0.00 0.00 234284/234284 Tokenizer::readIdentifier() [11] +[28] 0.0 0.00 0.00 234284 Lexer::beginPosition() [28] +----------------------------------------------- + 0.00 0.00 234284/234284 Tokenizer::readIdentifier() [11] +[29] 0.0 0.00 0.00 234284 Lexer::acceptPosition() [29] +----------------------------------------------- + 0.00 0.00 230202/230202 Tokenizer::scope() [4] +[30] 0.0 0.00 0.00 230202 OperatorToken::OperatorToken() [30] +----------------------------------------------- + 0.00 0.00 230202/230202 cmdTokens(CliArgs const&) [2] +[31] 0.0 0.00 0.00 230202 OperatorToken::~OperatorToken() [31] +----------------------------------------------- + 0.00 0.00 133847/133847 cmdTokens(CliArgs const&) [2] +[32] 0.0 0.00 0.00 133847 NumberToken::~NumberToken() [32] +----------------------------------------------- + 0.00 0.00 58981/58981 cmdTokens(CliArgs const&) [2] +[33] 0.0 0.00 0.00 58981 KeywordToken::~KeywordToken() [33] +----------------------------------------------- + 0.00 0.00 1/21 readSource[abi:cxx11](CliArgs const&) [46] + 0.00 0.00 2/21 cmdTokens(CliArgs const&) [2] + 0.00 0.00 4/21 main [1] + 0.00 0.00 14/21 std::vector >::push_back(CliCommand const&) [39] +[34] 0.0 0.00 0.00 21 void std::__cxx11::basic_string, std::allocator >::_M_construct(char const*, unsigned long) [34] +----------------------------------------------- + 0.00 0.00 2/20 parseArgs(int, char**) [47] + 0.00 0.00 18/20 main [1] +[35] 0.0 0.00 0.00 20 std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) [35] +----------------------------------------------- + 0.00 0.00 3/19 std::vector >::push_back(CliCommand const&) [39] + 0.00 0.00 4/19 parseArgs(int, char**) [47] + 0.00 0.00 5/19 CliCommand::~CliCommand() [38] + 0.00 0.00 7/19 main [1] +[36] 0.0 0.00 0.00 19 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [36] +----------------------------------------------- + 0.00 0.00 1/11 main [1] + 0.00 0.00 10/11 parseArgs(int, char**) [47] +[37] 0.0 0.00 0.00 11 bool std::operator==, std::allocator >(std::__cxx11::basic_string, std::allocator > const&, char const*) [37] +----------------------------------------------- + 0.00 0.00 9/9 main [1] +[38] 0.0 0.00 0.00 9 CliCommand::~CliCommand() [38] + 0.00 0.00 5/19 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [36] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [42] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [41] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [40] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [43] +----------------------------------------------- + 0.00 0.00 7/7 main [1] +[39] 0.0 0.00 0.00 7 std::vector >::push_back(CliCommand const&) [39] + 0.00 0.00 14/21 void std::__cxx11::basic_string, std::allocator >::_M_construct(char const*, unsigned long) [34] + 0.00 0.00 3/19 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [36] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [41] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [40] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [43] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [42] +----------------------------------------------- + 0.00 0.00 1/3 main [1] + 0.00 0.00 1/3 CliCommand::~CliCommand() [38] + 0.00 0.00 1/3 std::vector >::push_back(CliCommand const&) [39] +[40] 0.0 0.00 0.00 3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [40] +----------------------------------------------- + 0.00 0.00 1/3 main [1] + 0.00 0.00 1/3 CliCommand::~CliCommand() [38] + 0.00 0.00 1/3 std::vector >::push_back(CliCommand const&) [39] +[41] 0.0 0.00 0.00 3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [41] +----------------------------------------------- + 0.00 0.00 1/3 main [1] + 0.00 0.00 1/3 CliCommand::~CliCommand() [38] + 0.00 0.00 1/3 std::vector >::push_back(CliCommand const&) [39] +[42] 0.0 0.00 0.00 3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [42] +----------------------------------------------- + 0.00 0.00 1/3 main [1] + 0.00 0.00 1/3 CliCommand::~CliCommand() [38] + 0.00 0.00 1/3 std::vector >::push_back(CliCommand const&) [39] +[43] 0.0 0.00 0.00 3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [43] +----------------------------------------------- + 0.00 0.00 2/2 __static_initialization_and_destruction_0() [69] +[44] 0.0 0.00 0.00 2 std::_Hashtable > >, std::allocator > > >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Hashtable > > const*>(std::pair > > const*, std::pair > > const*, unsigned long, std::hash const&, std::equal_to const&, std::allocator > > > const&, std::integral_constant) [44] +----------------------------------------------- + 0.00 0.00 2/2 __static_initialization_and_destruction_0() [69] +[45] 0.0 0.00 0.00 2 std::_Hashtable >, std::pair > const, TokenType>, std::allocator > const, TokenType> >, std::__detail::_Select1st, std::equal_to > >, std::hash > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Hashtable > const, TokenType> const*>(std::pair > const, TokenType> const*, std::pair > const, TokenType> const*, unsigned long, std::hash > > const&, std::equal_to > > const&, std::allocator > const, TokenType> > const&, std::integral_constant) [45] +----------------------------------------------- + 0.00 0.00 1/1 cmdTokens(CliArgs const&) [2] +[46] 0.0 0.00 0.00 1 readSource[abi:cxx11](CliArgs const&) [46] + 0.00 0.00 1/21 void std::__cxx11::basic_string, std::allocator >::_M_construct(char const*, unsigned long) [34] +----------------------------------------------- + 0.00 0.00 1/1 main [1] +[47] 0.0 0.00 0.00 1 parseArgs(int, char**) [47] + 0.00 0.00 10/11 bool std::operator==, std::allocator >(std::__cxx11::basic_string, std::allocator > const&, char const*) [37] + 0.00 0.00 4/19 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [36] + 0.00 0.00 2/20 std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) [35] +----------------------------------------------- + 0.00 0.00 1/1 Lexer::setSourceText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) [50] +[48] 0.0 0.00 0.00 1 SourceFile::computeLineStarts() [48] +----------------------------------------------- + 0.00 0.00 1/1 Lexer::setSourceText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) [50] +[49] 0.0 0.00 0.00 1 SourceFile::setText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) [49] +----------------------------------------------- + 0.00 0.00 1/1 Tokenizer::scan(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator >) [3] +[50] 0.0 0.00 0.00 1 Lexer::setSourceText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) [50] + 0.00 0.00 1/1 SourceFile::computeLineStarts() [48] + 0.00 0.00 1/1 SourceFile::setText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) [49] +----------------------------------------------- + 0.00 0.00 1/1 main [1] +[51] 0.0 0.00 0.00 1 std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) [51] +----------------------------------------------- + + This table describes the call tree of the program, and was sorted by + the total amount of time spent in each function and its children. + + Each entry in this table consists of several lines. The line with the + index number at the left hand margin lists the current function. + The lines above it list the functions that called this function, + and the lines below it list the functions this one called. + This line lists: + index A unique number given to each element of the table. + Index numbers are sorted numerically. + The index number is printed next to every function name so + it is easier to look up where the function is in the table. + + % time This is the percentage of the `total' time that was spent + in this function and its children. Note that due to + different viewpoints, functions excluded by options, etc, + these numbers will NOT add up to 100%. + + self This is the total amount of time spent in this function. + + children This is the total amount of time propagated into this + function by its children. + + called This is the number of times the function was called. + If the function called itself recursively, the number + only includes non-recursive calls, and is followed by + a `+' and the number of recursive calls. + + name The name of the current function. The index number is + printed after it. If the function is a member of a + cycle, the cycle number is printed between the + function's name and the index number. + + + For the function's parents, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the function into this parent. + + children This is the amount of time that was propagated from + the function's children into this parent. + + called This is the number of times this parent called the + function `/' the total number of times the function + was called. Recursive calls to the function are not + included in the number after the `/'. + + name This is the name of the parent. The parent's index + number is printed after it. If the parent is a + member of a cycle, the cycle number is printed between + the name and the index number. + + If the parents of the function cannot be determined, the word + `' is printed in the `name' field, and all the other + fields are blank. + + For the function's children, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the child into the function. + + children This is the amount of time that was propagated from the + child's children to the function. + + called This is the number of times the function called + this child `/' the total number of times the child + was called. Recursive calls by the child are not + listed in the number after the `/'. + + name This is the name of the child. The child's index + number is printed after it. If the child is a + member of a cycle, the cycle number is printed + between the name and the index number. + + If there are any cycles (circles) in the call graph, there is an + entry for the cycle-as-a-whole. This entry shows who called the + cycle (as parents) and the members of the cycle (as children.) + The `+' recursive calls entry shows the number of function calls that + were internal to the cycle, and the calls entry for each member shows, + for that member, how many times it was called from other members of + the cycle. + +Copyright (C) 2012-2026 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Index by function name + + [46] readSource[abi:cxx11](CliArgs const&) [28] Lexer::beginPosition() [5] SourceFile::offsetToLocation(int) const + [2] cmdTokens(CliArgs const&) [50] Lexer::setSourceText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) [44] std::_Hashtable > >, std::allocator > > >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Hashtable > > const*>(std::pair > > const*, std::pair > > const*, unsigned long, std::hash const&, std::equal_to const&, std::allocator > > > const&, std::integral_constant) + [47] parseArgs(int, char**) [29] Lexer::acceptPosition() [45] std::_Hashtable >, std::pair > const, TokenType>, std::allocator > const, TokenType> >, std::__detail::_Select1st, std::equal_to > >, std::hash > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Hashtable > const, TokenType> const*>(std::pair > const, TokenType> const*, std::pair > const, TokenType> const*, unsigned long, std::hash > > const&, std::equal_to > > const&, std::allocator > const, TokenType> > const&, std::integral_constant) + [38] CliCommand::~CliCommand() [22] Lexer::skipWhiteSpace() [36] std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) + [48] SourceFile::computeLineStarts() [18] Lexer::isEnd() [51] std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) + [49] SourceFile::setText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) [25] Lexer::toChar(int) [40] std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) (std_function.h) + [32] NumberToken::~NumberToken() [24] Lexer::getchar(int) [41] std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) (std_function.h) + [33] KeywordToken::~KeywordToken() [19] Lexer::getchar() [42] std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) (std_function.h) + [30] OperatorToken::OperatorToken() [20] Lexer::include(std::basic_string_view >, bool) [35] std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) (std_function.h) + [31] OperatorToken::~OperatorToken() [26] Lexer::nextChar() [43] std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) (std_function.h) + [10] DelimiterToken::DelimiterToken() [21] Lexer::getOffset() [39] std::vector >::push_back(CliCommand const&) + [9] DelimiterToken::~DelimiterToken() [8] Lexer::isNumeric() [34] void std::__cxx11::basic_string, std::allocator >::_M_construct(char const*, unsigned long) + [27] IdentifierToken::~IdentifierToken() [11] Tokenizer::readIdentifier() [23] std::__detail::_Map_base, std::allocator >, std::pair, std::allocator > const, int>, std::allocator, std::allocator > const, int> >, std::__detail::_Select1st, std::equal_to, std::allocator > >, std::hash, std::allocator > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits, true>::operator[](std::__cxx11::basic_string, std::allocator > const&) + [6] Lexer::getLocation() [3] Tokenizer::scan(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator >) [37] bool std::operator==, std::allocator >(std::__cxx11::basic_string, std::allocator > const&, char const*) + [7] Lexer::readNumeric() [4] Tokenizer::scope() diff --git a/docs/perf-before.txt b/docs/perf-before.txt new file mode 100644 index 0000000..8bd86fa --- /dev/null +++ b/docs/perf-before.txt @@ -0,0 +1,406 @@ +Flat profile: + +Each sample counts as 0.01 seconds. + % cumulative self self total + time seconds seconds calls ms/call ms/call name + 81.25 0.26 0.26 66967977 0.00 0.00 Lexer::include(std::basic_string_view >, bool) + 9.38 0.29 0.03 1059636 0.00 0.00 Tokenizer::scope() + 6.25 0.31 0.02 _init + 3.12 0.32 0.01 1064503 0.00 0.00 SourceFile::offsetToLocation(int) const + 0.00 0.32 0.00 2509314 0.00 0.00 Lexer::isEnd() + 0.00 0.32 0.00 1851576 0.00 0.00 Lexer::getOffset() + 0.00 0.32 0.00 1449678 0.00 0.00 Lexer::getchar() + 0.00 0.32 0.00 1059640 0.00 0.00 Lexer::skipWhiteSpace() + 0.00 0.32 0.00 1059635 0.00 0.00 Lexer::isNumeric() + 0.00 0.32 0.00 750485 0.00 0.00 Lexer::getLocation() + 0.00 0.32 0.00 750485 0.00 0.00 Lexer::toChar(int) + 0.00 0.32 0.00 461302 0.00 0.00 DelimiterToken::~DelimiterToken() + 0.00 0.32 0.00 230202 0.00 0.00 OperatorToken::~OperatorToken() + 0.00 0.32 0.00 214740 0.00 0.00 Lexer::nextChar() + 0.00 0.32 0.00 175303 0.00 0.00 IdentifierToken::~IdentifierToken() + 0.00 0.32 0.00 175303 0.00 0.00 Lexer::beginPosition() + 0.00 0.32 0.00 175303 0.00 0.00 Lexer::acceptPosition() + 0.00 0.32 0.00 175303 0.00 0.00 Tokenizer::readIdentifier() + 0.00 0.32 0.00 133847 0.00 0.00 NumberToken::~NumberToken() + 0.00 0.32 0.00 133847 0.00 0.00 Lexer::readNumeric() + 0.00 0.32 0.00 58981 0.00 0.00 KeywordToken::~KeywordToken() + 0.00 0.32 0.00 58981 0.00 0.00 Lexer::getchar(int) + 0.00 0.32 0.00 21 0.00 0.00 void std::__cxx11::basic_string, std::allocator >::_M_construct(char const*, unsigned long) + 0.00 0.32 0.00 20 0.00 0.00 std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) + 0.00 0.32 0.00 19 0.00 0.00 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) + 0.00 0.32 0.00 11 0.00 0.00 bool std::operator==, std::allocator >(std::__cxx11::basic_string, std::allocator > const&, char const*) + 0.00 0.32 0.00 9 0.00 0.00 CliCommand::~CliCommand() + 0.00 0.32 0.00 7 0.00 0.00 std::vector >::push_back(CliCommand const&) + 0.00 0.32 0.00 3 0.00 0.00 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) + 0.00 0.32 0.00 3 0.00 0.00 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) + 0.00 0.32 0.00 3 0.00 0.00 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) + 0.00 0.32 0.00 3 0.00 0.00 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) + 0.00 0.32 0.00 2 0.00 0.00 std::_Hashtable > >, std::allocator > > >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Hashtable > > const*>(std::pair > > const*, std::pair > > const*, unsigned long, std::hash const&, std::equal_to const&, std::allocator > > > const&, std::integral_constant) + 0.00 0.32 0.00 2 0.00 0.00 std::_Hashtable >, std::pair > const, TokenType>, std::allocator > const, TokenType> >, std::__detail::_Select1st, std::equal_to > >, std::hash > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Hashtable > const, TokenType> const*>(std::pair > const, TokenType> const*, std::pair > const, TokenType> const*, unsigned long, std::hash > > const&, std::equal_to > > const&, std::allocator > const, TokenType> > const&, std::integral_constant) + 0.00 0.32 0.00 1 0.00 0.00 readSource[abi:cxx11](CliArgs const&) + 0.00 0.32 0.00 1 0.00 300.00 cmdTokens(CliArgs const&) + 0.00 0.32 0.00 1 0.00 0.00 parseArgs(int, char**) + 0.00 0.32 0.00 1 0.00 0.00 SourceFile::computeLineStarts() + 0.00 0.32 0.00 1 0.00 0.00 SourceFile::setText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) + 0.00 0.32 0.00 1 0.00 0.00 Lexer::setSourceText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) + 0.00 0.32 0.00 1 0.00 300.00 Tokenizer::scan(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator >) + 0.00 0.32 0.00 1 0.00 0.00 std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) + + % the percentage of the total running time of the +time program used by this function. + +cumulative a running sum of the number of seconds accounted + seconds for by this function and those listed above it. + + self the number of seconds accounted for by this +seconds function alone. This is the major sort for this + listing. + +calls the number of times this function was invoked, if + this function is profiled, else blank. + + self the average number of milliseconds spent in this +ms/call function per call, if this function is profiled, + else blank. + + total the average number of milliseconds spent in this +ms/call function and its descendents per call, if this + function is profiled, else blank. + +name the name of the function. This is the minor sort + for this listing. The index shows the location of + the function in the gprof listing. If the index is + in parenthesis it shows where it would appear in + the gprof listing if it were to be printed. + +Copyright (C) 2012-2026 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + + Call graph (explanation follows) + + +granularity: each sample hit covers 4 byte(s) for 3.12% of 0.32 seconds + +index % time self children called name + +[1] 93.8 0.00 0.30 main [1] + 0.00 0.30 1/1 cmdTokens(CliArgs const&) [2] + 0.00 0.00 18/20 std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) [33] + 0.00 0.00 9/9 CliCommand::~CliCommand() [36] + 0.00 0.00 7/19 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [34] + 0.00 0.00 7/7 std::vector >::push_back(CliCommand const&) [37] + 0.00 0.00 4/21 void std::__cxx11::basic_string, std::allocator >::_M_construct(char const*, unsigned long) [32] + 0.00 0.00 1/1 parseArgs(int, char**) [45] + 0.00 0.00 1/11 bool std::operator==, std::allocator >(std::__cxx11::basic_string, std::allocator > const&, char const*) [35] + 0.00 0.00 1/1 std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) [49] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [40] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [39] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [38] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [41] +----------------------------------------------- + 0.00 0.30 1/1 main [1] +[2] 93.8 0.00 0.30 1 cmdTokens(CliArgs const&) [2] + 0.00 0.30 1/1 Tokenizer::scan(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator >) [3] + 0.00 0.00 461302/461302 DelimiterToken::~DelimiterToken() [23] + 0.00 0.00 230202/230202 OperatorToken::~OperatorToken() [24] + 0.00 0.00 175303/175303 IdentifierToken::~IdentifierToken() [26] + 0.00 0.00 133847/133847 NumberToken::~NumberToken() [29] + 0.00 0.00 58981/58981 KeywordToken::~KeywordToken() [30] + 0.00 0.00 2/21 void std::__cxx11::basic_string, std::allocator >::_M_construct(char const*, unsigned long) [32] + 0.00 0.00 1/1 readSource[abi:cxx11](CliArgs const&) [44] +----------------------------------------------- + 0.00 0.30 1/1 cmdTokens(CliArgs const&) [2] +[3] 93.8 0.00 0.30 1 Tokenizer::scan(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator >) [3] + 0.03 0.27 1059636/1059636 Tokenizer::scope() [4] + 0.00 0.00 175303/175303 Tokenizer::readIdentifier() [9] + 0.00 0.00 1059635/2509314 Lexer::isEnd() [17] + 0.00 0.00 1/1 Lexer::setSourceText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) [48] +----------------------------------------------- + 0.03 0.27 1059636/1059636 Tokenizer::scan(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator >) [3] +[4] 93.2 0.03 0.27 1059636 Tokenizer::scope() [4] + 0.26 0.00 66967977/66967977 Lexer::include(std::basic_string_view >, bool) [5] + 0.00 0.01 750485/750485 Lexer::getLocation() [8] + 0.00 0.00 133847/133847 Lexer::readNumeric() [10] + 0.00 0.00 1500970/1851576 Lexer::getOffset() [18] + 0.00 0.00 1059774/2509314 Lexer::isEnd() [17] + 0.00 0.00 1059773/1449678 Lexer::getchar() [19] + 0.00 0.00 1059640/1059640 Lexer::skipWhiteSpace() [20] + 0.00 0.00 1059635/1059635 Lexer::isNumeric() [21] + 0.00 0.00 750485/750485 Lexer::toChar(int) [22] + 0.00 0.00 58981/58981 Lexer::getchar(int) [31] + 0.00 0.00 138/214740 Lexer::nextChar() [25] +----------------------------------------------- + 0.26 0.00 66967977/66967977 Tokenizer::scope() [4] +[5] 81.2 0.26 0.00 66967977 Lexer::include(std::basic_string_view >, bool) [5] +----------------------------------------------- + +[6] 6.2 0.02 0.00 _init [6] +----------------------------------------------- + 0.00 0.00 138715/1064503 Lexer::readNumeric() [10] + 0.00 0.00 175303/1064503 Tokenizer::readIdentifier() [9] + 0.01 0.00 750485/1064503 Lexer::getLocation() [8] +[7] 3.1 0.01 0.00 1064503 SourceFile::offsetToLocation(int) const [7] +----------------------------------------------- + 0.00 0.01 750485/750485 Tokenizer::scope() [4] +[8] 2.2 0.00 0.01 750485 Lexer::getLocation() [8] + 0.01 0.00 750485/1064503 SourceFile::offsetToLocation(int) const [7] +----------------------------------------------- + 0.00 0.00 175303/175303 Tokenizer::scan(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator >) [3] +[9] 0.5 0.00 0.00 175303 Tokenizer::readIdentifier() [9] + 0.00 0.00 175303/1064503 SourceFile::offsetToLocation(int) const [7] + 0.00 0.00 389905/2509314 Lexer::isEnd() [17] + 0.00 0.00 389905/1449678 Lexer::getchar() [19] + 0.00 0.00 350606/1851576 Lexer::getOffset() [18] + 0.00 0.00 214602/214740 Lexer::nextChar() [25] + 0.00 0.00 175303/175303 Lexer::beginPosition() [27] + 0.00 0.00 175303/175303 Lexer::acceptPosition() [28] +----------------------------------------------- + 0.00 0.00 133847/133847 Tokenizer::scope() [4] +[10] 0.4 0.00 0.00 133847 Lexer::readNumeric() [10] + 0.00 0.00 138715/1064503 SourceFile::offsetToLocation(int) const [7] +----------------------------------------------- + 0.00 0.00 389905/2509314 Tokenizer::readIdentifier() [9] + 0.00 0.00 1059635/2509314 Tokenizer::scan(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator >) [3] + 0.00 0.00 1059774/2509314 Tokenizer::scope() [4] +[17] 0.0 0.00 0.00 2509314 Lexer::isEnd() [17] +----------------------------------------------- + 0.00 0.00 350606/1851576 Tokenizer::readIdentifier() [9] + 0.00 0.00 1500970/1851576 Tokenizer::scope() [4] +[18] 0.0 0.00 0.00 1851576 Lexer::getOffset() [18] +----------------------------------------------- + 0.00 0.00 389905/1449678 Tokenizer::readIdentifier() [9] + 0.00 0.00 1059773/1449678 Tokenizer::scope() [4] +[19] 0.0 0.00 0.00 1449678 Lexer::getchar() [19] +----------------------------------------------- + 0.00 0.00 1059640/1059640 Tokenizer::scope() [4] +[20] 0.0 0.00 0.00 1059640 Lexer::skipWhiteSpace() [20] +----------------------------------------------- + 0.00 0.00 1059635/1059635 Tokenizer::scope() [4] +[21] 0.0 0.00 0.00 1059635 Lexer::isNumeric() [21] +----------------------------------------------- + 0.00 0.00 750485/750485 Tokenizer::scope() [4] +[22] 0.0 0.00 0.00 750485 Lexer::toChar(int) [22] +----------------------------------------------- + 0.00 0.00 461302/461302 cmdTokens(CliArgs const&) [2] +[23] 0.0 0.00 0.00 461302 DelimiterToken::~DelimiterToken() [23] +----------------------------------------------- + 0.00 0.00 230202/230202 cmdTokens(CliArgs const&) [2] +[24] 0.0 0.00 0.00 230202 OperatorToken::~OperatorToken() [24] +----------------------------------------------- + 0.00 0.00 138/214740 Tokenizer::scope() [4] + 0.00 0.00 214602/214740 Tokenizer::readIdentifier() [9] +[25] 0.0 0.00 0.00 214740 Lexer::nextChar() [25] +----------------------------------------------- + 0.00 0.00 175303/175303 cmdTokens(CliArgs const&) [2] +[26] 0.0 0.00 0.00 175303 IdentifierToken::~IdentifierToken() [26] +----------------------------------------------- + 0.00 0.00 175303/175303 Tokenizer::readIdentifier() [9] +[27] 0.0 0.00 0.00 175303 Lexer::beginPosition() [27] +----------------------------------------------- + 0.00 0.00 175303/175303 Tokenizer::readIdentifier() [9] +[28] 0.0 0.00 0.00 175303 Lexer::acceptPosition() [28] +----------------------------------------------- + 0.00 0.00 133847/133847 cmdTokens(CliArgs const&) [2] +[29] 0.0 0.00 0.00 133847 NumberToken::~NumberToken() [29] +----------------------------------------------- + 0.00 0.00 58981/58981 cmdTokens(CliArgs const&) [2] +[30] 0.0 0.00 0.00 58981 KeywordToken::~KeywordToken() [30] +----------------------------------------------- + 0.00 0.00 58981/58981 Tokenizer::scope() [4] +[31] 0.0 0.00 0.00 58981 Lexer::getchar(int) [31] +----------------------------------------------- + 0.00 0.00 1/21 readSource[abi:cxx11](CliArgs const&) [44] + 0.00 0.00 2/21 cmdTokens(CliArgs const&) [2] + 0.00 0.00 4/21 main [1] + 0.00 0.00 14/21 std::vector >::push_back(CliCommand const&) [37] +[32] 0.0 0.00 0.00 21 void std::__cxx11::basic_string, std::allocator >::_M_construct(char const*, unsigned long) [32] +----------------------------------------------- + 0.00 0.00 2/20 parseArgs(int, char**) [45] + 0.00 0.00 18/20 main [1] +[33] 0.0 0.00 0.00 20 std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) [33] +----------------------------------------------- + 0.00 0.00 3/19 std::vector >::push_back(CliCommand const&) [37] + 0.00 0.00 4/19 parseArgs(int, char**) [45] + 0.00 0.00 5/19 CliCommand::~CliCommand() [36] + 0.00 0.00 7/19 main [1] +[34] 0.0 0.00 0.00 19 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [34] +----------------------------------------------- + 0.00 0.00 1/11 main [1] + 0.00 0.00 10/11 parseArgs(int, char**) [45] +[35] 0.0 0.00 0.00 11 bool std::operator==, std::allocator >(std::__cxx11::basic_string, std::allocator > const&, char const*) [35] +----------------------------------------------- + 0.00 0.00 9/9 main [1] +[36] 0.0 0.00 0.00 9 CliCommand::~CliCommand() [36] + 0.00 0.00 5/19 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [34] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [40] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [39] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [38] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [41] +----------------------------------------------- + 0.00 0.00 7/7 main [1] +[37] 0.0 0.00 0.00 7 std::vector >::push_back(CliCommand const&) [37] + 0.00 0.00 14/21 void std::__cxx11::basic_string, std::allocator >::_M_construct(char const*, unsigned long) [32] + 0.00 0.00 3/19 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [34] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [39] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [38] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [41] + 0.00 0.00 1/3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [40] +----------------------------------------------- + 0.00 0.00 1/3 main [1] + 0.00 0.00 1/3 CliCommand::~CliCommand() [36] + 0.00 0.00 1/3 std::vector >::push_back(CliCommand const&) [37] +[38] 0.0 0.00 0.00 3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [38] +----------------------------------------------- + 0.00 0.00 1/3 main [1] + 0.00 0.00 1/3 CliCommand::~CliCommand() [36] + 0.00 0.00 1/3 std::vector >::push_back(CliCommand const&) [37] +[39] 0.0 0.00 0.00 3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [39] +----------------------------------------------- + 0.00 0.00 1/3 main [1] + 0.00 0.00 1/3 CliCommand::~CliCommand() [36] + 0.00 0.00 1/3 std::vector >::push_back(CliCommand const&) [37] +[40] 0.0 0.00 0.00 3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [40] +----------------------------------------------- + 0.00 0.00 1/3 main [1] + 0.00 0.00 1/3 CliCommand::~CliCommand() [36] + 0.00 0.00 1/3 std::vector >::push_back(CliCommand const&) [37] +[41] 0.0 0.00 0.00 3 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [41] +----------------------------------------------- + 0.00 0.00 2/2 __static_initialization_and_destruction_0() [66] +[42] 0.0 0.00 0.00 2 std::_Hashtable > >, std::allocator > > >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Hashtable > > const*>(std::pair > > const*, std::pair > > const*, unsigned long, std::hash const&, std::equal_to const&, std::allocator > > > const&, std::integral_constant) [42] +----------------------------------------------- + 0.00 0.00 2/2 __static_initialization_and_destruction_0() [66] +[43] 0.0 0.00 0.00 2 std::_Hashtable >, std::pair > const, TokenType>, std::allocator > const, TokenType> >, std::__detail::_Select1st, std::equal_to > >, std::hash > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Hashtable > const, TokenType> const*>(std::pair > const, TokenType> const*, std::pair > const, TokenType> const*, unsigned long, std::hash > > const&, std::equal_to > > const&, std::allocator > const, TokenType> > const&, std::integral_constant) [43] +----------------------------------------------- + 0.00 0.00 1/1 cmdTokens(CliArgs const&) [2] +[44] 0.0 0.00 0.00 1 readSource[abi:cxx11](CliArgs const&) [44] + 0.00 0.00 1/21 void std::__cxx11::basic_string, std::allocator >::_M_construct(char const*, unsigned long) [32] +----------------------------------------------- + 0.00 0.00 1/1 main [1] +[45] 0.0 0.00 0.00 1 parseArgs(int, char**) [45] + 0.00 0.00 10/11 bool std::operator==, std::allocator >(std::__cxx11::basic_string, std::allocator > const&, char const*) [35] + 0.00 0.00 4/19 std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) [34] + 0.00 0.00 2/20 std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) [33] +----------------------------------------------- + 0.00 0.00 1/1 Lexer::setSourceText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) [48] +[46] 0.0 0.00 0.00 1 SourceFile::computeLineStarts() [46] +----------------------------------------------- + 0.00 0.00 1/1 Lexer::setSourceText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) [48] +[47] 0.0 0.00 0.00 1 SourceFile::setText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) [47] +----------------------------------------------- + 0.00 0.00 1/1 Tokenizer::scan(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator >) [3] +[48] 0.0 0.00 0.00 1 Lexer::setSourceText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) [48] + 0.00 0.00 1/1 SourceFile::computeLineStarts() [46] + 0.00 0.00 1/1 SourceFile::setText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) [47] +----------------------------------------------- + 0.00 0.00 1/1 main [1] +[49] 0.0 0.00 0.00 1 std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) [49] +----------------------------------------------- + + This table describes the call tree of the program, and was sorted by + the total amount of time spent in each function and its children. + + Each entry in this table consists of several lines. The line with the + index number at the left hand margin lists the current function. + The lines above it list the functions that called this function, + and the lines below it list the functions this one called. + This line lists: + index A unique number given to each element of the table. + Index numbers are sorted numerically. + The index number is printed next to every function name so + it is easier to look up where the function is in the table. + + % time This is the percentage of the `total' time that was spent + in this function and its children. Note that due to + different viewpoints, functions excluded by options, etc, + these numbers will NOT add up to 100%. + + self This is the total amount of time spent in this function. + + children This is the total amount of time propagated into this + function by its children. + + called This is the number of times the function was called. + If the function called itself recursively, the number + only includes non-recursive calls, and is followed by + a `+' and the number of recursive calls. + + name The name of the current function. The index number is + printed after it. If the function is a member of a + cycle, the cycle number is printed between the + function's name and the index number. + + + For the function's parents, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the function into this parent. + + children This is the amount of time that was propagated from + the function's children into this parent. + + called This is the number of times this parent called the + function `/' the total number of times the function + was called. Recursive calls to the function are not + included in the number after the `/'. + + name This is the name of the parent. The parent's index + number is printed after it. If the parent is a + member of a cycle, the cycle number is printed between + the name and the index number. + + If the parents of the function cannot be determined, the word + `' is printed in the `name' field, and all the other + fields are blank. + + For the function's children, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the child into the function. + + children This is the amount of time that was propagated from the + child's children to the function. + + called This is the number of times the function called + this child `/' the total number of times the child + was called. Recursive calls by the child are not + listed in the number after the `/'. + + name This is the name of the child. The child's index + number is printed after it. If the child is a + member of a cycle, the cycle number is printed + between the name and the index number. + + If there are any cycles (circles) in the call graph, there is an + entry for the cycle-as-a-whole. This entry shows who called the + cycle (as parents) and the members of the cycle (as children.) + The `+' recursive calls entry shows the number of function calls that + were internal to the cycle, and the calls entry for each member shows, + for that member, how many times it was called from other members of + the cycle. + +Copyright (C) 2012-2026 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Index by function name + + [44] readSource[abi:cxx11](CliArgs const&) [48] Lexer::setSourceText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) [7] SourceFile::offsetToLocation(int) const + [2] cmdTokens(CliArgs const&) [28] Lexer::acceptPosition() [42] std::_Hashtable > >, std::allocator > > >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Hashtable > > const*>(std::pair > > const*, std::pair > > const*, unsigned long, std::hash const&, std::equal_to const&, std::allocator > > > const&, std::integral_constant) + [45] parseArgs(int, char**) [20] Lexer::skipWhiteSpace() [43] std::_Hashtable >, std::pair > const, TokenType>, std::allocator > const, TokenType> >, std::__detail::_Select1st, std::equal_to > >, std::hash > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Hashtable > const, TokenType> const*>(std::pair > const, TokenType> const*, std::pair > const, TokenType> const*, unsigned long, std::hash > > const&, std::equal_to > > const&, std::allocator > const, TokenType> > const&, std::integral_constant) + [36] CliCommand::~CliCommand() [17] Lexer::isEnd() [34] std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) + [46] SourceFile::computeLineStarts() [22] Lexer::toChar(int) [49] std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) + [47] SourceFile::setText(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&) [31] Lexer::getchar(int) [38] std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) (std_function.h) + [29] NumberToken::~NumberToken() [19] Lexer::getchar() [39] std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) (std_function.h) + [30] KeywordToken::~KeywordToken() [5] Lexer::include(std::basic_string_view >, bool) [40] std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) (std_function.h) + [24] OperatorToken::~OperatorToken() [25] Lexer::nextChar() [33] std::_Function_handler::_M_invoke(std::_Any_data const&, CliArgs const&) (std_function.h) + [23] DelimiterToken::~DelimiterToken() [18] Lexer::getOffset() [41] std::_Function_handler::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) (std_function.h) + [26] IdentifierToken::~IdentifierToken() [21] Lexer::isNumeric() [37] std::vector >::push_back(CliCommand const&) + [8] Lexer::getLocation() [9] Tokenizer::readIdentifier() [32] void std::__cxx11::basic_string, std::allocator >::_M_construct(char const*, unsigned long) + [10] Lexer::readNumeric() [3] Tokenizer::scan(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator >) [35] bool std::operator==, std::allocator >(std::__cxx11::basic_string, std::allocator > const&, char const*) + [27] Lexer::beginPosition() [4] Tokenizer::scope() [6] _init diff --git a/src/tokenizer/tokenizer.cpp b/src/tokenizer/tokenizer.cpp index 1e0f1f7..d1ca5c1 100644 --- a/src/tokenizer/tokenizer.cpp +++ b/src/tokenizer/tokenizer.cpp @@ -1,5 +1,58 @@ #include "tokenizer/tokenizer.hpp" +#include +// ───────────────────────────────────────────────────────────────────────────── +// Keyword hash map — O(1) lookup yerine O(n) for döngüsü +// ───────────────────────────────────────────────────────────────────────────── +static const std::unordered_map KW_MAP = { + {"if","if"},{"else","else"},{"for","for"},{"while","while"},{"do","do"}, + {"switch","switch"},{"case","case"},{"default","default"}, + {"break","break"},{"continue","continue"},{"return","return"}, + {"try","try"},{"catch","catch"},{"finally","finally"}, + {"throw","throw"},{"throws","throws"},{"assert","assert"}, + {"void","void"},{"int","int"},{"float","float"},{"double","double"}, + {"char","char"},{"string","string"},{"bool","bool"}, + {"true","true"},{"false","false"},{"null","null"}, + {"class","class"},{"struct","struct"},{"interface","interface"}, + {"enum","enum"},{"extends","extends"},{"implements","implements"}, + {"new","new"},{"public","public"},{"private","private"}, + {"protected","protected"},{"static","static"},{"final","final"}, + {"abstract","abstract"},{"import","import"},{"package","package"}, + {"const","const"},{"extern","extern"},{"typedef","typedef"}, + {"sizeof","sizeof"},{"auto","auto"},{"constexpr","constexpr"}, + {"noexcept","noexcept"},{"native","native"}, + {"synchronized","synchronized"},{"volatile","volatile"}, + {"transient","transient"} +}; + +// ───────────────────────────────────────────────────────────────────────────── +// Yardımcı makrolar — OperatorToken ve DelimiterToken üretimi +// ───────────────────────────────────────────────────────────────────────────── +#define MAKE_OP(str, len) \ + do { \ + OperatorToken* _t = new OperatorToken();\ + _t->start = hmx.getOffset(); \ + _t->loc = hmx.getLocation(); \ + hmx.toChar(len); \ + _t->end = hmx.getOffset(); \ + _t->token = (str); \ + return _t; \ + } while(0) + +#define MAKE_DEL(str, len) \ + do { \ + DelimiterToken* _t = new DelimiterToken();\ + _t->start = hmx.getOffset(); \ + _t->loc = hmx.getLocation(); \ + hmx.toChar(len); \ + _t->end = hmx.getOffset(); \ + _t->token = (str); \ + return _t; \ + } while(0) + +// ───────────────────────────────────────────────────────────────────────────── +// scan +// ───────────────────────────────────────────────────────────────────────────── std::vector Tokenizer::scan(std::string input, std::string filePath) { std::vector tokens; hmx.setSourceText(filePath, input); @@ -12,10 +65,14 @@ std::vector Tokenizer::scan(std::string input, std::string filePath) { return tokens; } +// ───────────────────────────────────────────────────────────────────────────── +// scope — ana dispatch; her token için TEK geçiş +// ───────────────────────────────────────────────────────────────────────────── Token* Tokenizer::scope() { hmx.skipWhiteSpace(); - if (hmx.include("//", true)) { skipOneLineComment(); return scope(); } + // Yorum satırları — include() burada hâlâ gerekli (2 karakter kontrol) + if (hmx.include("//", true)) { skipOneLineComment(); return scope(); } if (hmx.include("/*", true)) { skipMultiLineComment(); return scope(); } if (hmx.isEnd()) { @@ -24,10 +81,8 @@ Token* Tokenizer::scope() { return t; } - if (hmx.getchar() == '"') - return readString(); - - if (hmx.isNumeric()) { + if (hmx.getchar() == '"') return readString(); + if (hmx.isNumeric()) { INumber lem = hmx.readNumeric(); NumberToken* nt = new NumberToken(); nt->loc = lem.startLoc; @@ -40,50 +95,128 @@ Token* Tokenizer::scope() { return nt; } - for (const auto& kw : keywords) { - if (hmx.include(kw, false)) { - char next = hmx.getchar(static_cast(kw.size())); - if ((next >= 'a' && next <= 'z') || (next >= 'A' && next <= 'Z') || - (next >= '0' && next <= '9') || next == '_' || next == '$') { - continue; + char c0 = hmx.getchar(); + char c1 = hmx.getchar(1); // sadece 1 ek okuma, include() değil + + // ── Operatörler & Delimiter'lar — switch ile O(1) dispatch ─────────── + switch (c0) { + // + ++ += + case '+': + if (c1 == '+') MAKE_OP("++", 2); + if (c1 == '=') MAKE_OP("+=", 2); + MAKE_OP("+", 1); + + // - -- -= -> + case '-': + if (c1 == '-') MAKE_OP("--", 2); + if (c1 == '=') MAKE_OP("-=", 2); + if (c1 == '>') MAKE_DEL("->", 2); + MAKE_OP("-", 1); + + // * *= ** + case '*': + if (c1 == '=') MAKE_OP("*=", 2); + if (c1 == '*') MAKE_OP("**", 2); + MAKE_OP("*", 1); + + // / /= + case '/': + if (c1 == '=') MAKE_OP("/=", 2); + MAKE_OP("/", 1); + + // % %= + case '%': + if (c1 == '=') MAKE_OP("%=", 2); + MAKE_OP("%", 1); + + // < <= << <<= + case '<': + if (c1 == '<') { + if (hmx.getchar(2) == '=') MAKE_OP("<<=", 3); + MAKE_OP("<<", 2); } - KeywordToken* kt = new KeywordToken(); - kt->start = hmx.getOffset(); - kt->loc = hmx.getLocation(); - hmx.toChar(static_cast(kw.size())); - kt->end = hmx.getOffset(); - kt->token = kw; - return kt; - } + if (c1 == '=') MAKE_OP("<=", 2); + MAKE_OP("<", 1); + + // > >= >> >>= + case '>': + if (c1 == '>') { + if (hmx.getchar(2) == '=') MAKE_OP(">>=", 3); + MAKE_OP(">>", 2); + } + if (c1 == '=') MAKE_OP(">=", 2); + MAKE_OP(">", 1); + + // = == + case '=': + if (c1 == '=') MAKE_OP("==", 2); + MAKE_OP("=", 1); + + // ! != + case '!': + if (c1 == '=') MAKE_OP("!=", 2); + MAKE_OP("!", 1); + + // & && &= + case '&': + if (c1 == '&') MAKE_OP("&&", 2); + if (c1 == '=') MAKE_OP("&=", 2); + MAKE_OP("&", 1); + + // | || |= + case '|': + if (c1 == '|') MAKE_OP("||", 2); + if (c1 == '=') MAKE_OP("|=", 2); + MAKE_OP("|", 1); + + // ^ ^= + case '^': + if (c1 == '=') MAKE_OP("^=", 2); + MAKE_OP("^", 1); + + // ~ (tek karakter) + case '~': MAKE_OP("~", 1); + + // : :: + case ':': + if (c1 == ':') MAKE_DEL("::", 2); + MAKE_DEL(":", 1); + + // Tek karakterli delimiter'lar + case '[': MAKE_DEL("[", 1); + case ']': MAKE_DEL("]", 1); + case '(': MAKE_DEL("(", 1); + case ')': MAKE_DEL(")", 1); + case '{': MAKE_DEL("{", 1); + case '}': MAKE_DEL("}", 1); + case ';': MAKE_DEL(";", 1); + case ',': MAKE_DEL(",", 1); + case '.': MAKE_DEL(".", 1); + case '?': MAKE_OP("?", 1); + + default: break; } - for (const auto& del : delimiters) { - if (hmx.include(del, false)) { - DelimiterToken* dt = new DelimiterToken(); - dt->start = hmx.getOffset(); - dt->loc = hmx.getLocation(); - hmx.toChar(static_cast(del.size())); - dt->end = hmx.getOffset(); - dt->token = del; - return dt; - } + // ── Identifier veya Keyword — önce oku, sonra hash map'te ara ──────── + IdentifierToken* id = readIdentifier(); + + auto it = KW_MAP.find(id->token); + if (it != KW_MAP.end()) { + KeywordToken* kt = new KeywordToken(); + kt->start = id->start; + kt->end = id->end; + kt->loc = id->loc; + kt->token = id->token; + delete id; + return kt; } - for (const auto& op : operators) { - if (hmx.include(op, false)) { - OperatorToken* ot = new OperatorToken(); - ot->start = hmx.getOffset(); - ot->loc = hmx.getLocation(); - hmx.toChar(static_cast(op.size())); - ot->end = hmx.getOffset(); - ot->token = op; - return ot; - } - } - - return readIdentifier(); + return id; } +// ───────────────────────────────────────────────────────────────────────────── +// readIdentifier — değişmedi +// ───────────────────────────────────────────────────────────────────────────── IdentifierToken* Tokenizer::readIdentifier() { hmx.beginPosition(); IdentifierToken* it = new IdentifierToken(); @@ -115,6 +248,9 @@ IdentifierToken* Tokenizer::readIdentifier() { return it; } +// ───────────────────────────────────────────────────────────────────────────── +// readString — değişmedi +// ───────────────────────────────────────────────────────────────────────────── StringToken* Tokenizer::readString() { hmx.beginPosition(); StringToken* st = new StringToken(); @@ -127,11 +263,8 @@ StringToken* Tokenizer::readString() { st->token.push_back(c); switch (c) { case '"': - if (!started) { - started = true; - } else { - ended = true; - } + if (!started) { started = true; } + else { ended = true; } break; case '\\': hmx.nextChar(); @@ -154,6 +287,9 @@ StringToken* Tokenizer::readString() { return st; } +// ───────────────────────────────────────────────────────────────────────────── +// skipOneLineComment / skipMultiLineComment — değişmedi +// ───────────────────────────────────────────────────────────────────────────── void Tokenizer::skipOneLineComment() { while (!hmx.isEnd()) { if (hmx.getchar() == '\n') {