Skip to content

perf: faster text-table #5665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 12, 2025
Merged

perf: faster text-table #5665

merged 2 commits into from
Jun 12, 2025

Conversation

D-Sketon
Copy link
Member

@D-Sketon D-Sketon commented Jun 1, 2025

What does it do?

replace text-table with fast-text-table I created, which is smaller and faster.

benchmark

clk: ~4.18 GHz
cpu: 13th Gen Intel(R) Core(TM) i5-13400F
runtime: node 24.1.0 (x64-win32)

benchmark                   avg (min … max) p75 / p99    (min … top 1%)
------------------------------------------- -------------------------------
• table - small dataset
------------------------------------------- -------------------------------
fast-text-table                4.99 µs/iter   4.87 µs  █▂
                        (4.67 µs … 5.95 µs)   5.92 µs ▅██▇▂▂▁▁▁▁▁▁▁▁▁▁▃▃▄▃▂
                  gc(  2.41 ms …   4.42 ms)  13.29 kb ( 13.25 kb… 13.37 kb)

text-table                    20.23 µs/iter  20.24 µs        ██
                      (19.48 µs … 21.52 µs)  21.01 µs █▁▁█▁█▁████▁▁▁█▁▁▁▁▁█
                  gc(  2.47 ms …   4.59 ms)   3.13 kb (  3.08 kb…  3.17 kb)

summary
  fast-text-table
   4.05x faster than text-table

• table - middle dataset
------------------------------------------- -------------------------------
fast-text-table              263.47 µs/iter 276.20 µs    ▇▆ █▂
                    (194.60 µs … 465.30 µs) 436.00 µs ▂▂███▆██▃▄▃▂▂▃▂▁▁▁▁▁▁
                  gc(  2.29 ms …   5.08 ms) 543.81 kb (210.00 kb…801.07 kb)

text-table                     7.05 ms/iter   7.16 ms    █ ▄ ▆▃       ▄
                        (6.82 ms … 7.39 ms)   7.33 ms ▄▆▇███▆██▇█▇▇▆▆▆█▂▅▅▂
                  gc(  2.27 ms …   2.99 ms)   1.89 mb (  1.89 mb…  1.89 mb)

summary
  fast-text-table
   26.76x faster than text-table

• table - large dataset
------------------------------------------- -------------------------------
fast-text-table               10.39 ms/iter  10.51 ms  ▂   ▅█ ▂▂
                      (10.01 ms … 11.01 ms)  10.93 ms ▂█▇▃▄██▇██▆▆▃▂▇▁▆▂▃▃▃
                  gc(  2.32 ms …   3.02 ms)  34.06 mb ( 34.03 mb… 34.14 mb)

text-table                      5.43 s/iter    5.45 s     █
                          (5.38 s … 5.53 s)    5.47 s █▁▁██▁█▁▁█▁█▁▁█▁▁█▁██
                  gc(  2.64 ms …   3.78 ms)  75.76 mb ( 75.76 mb… 75.76 mb)

summary
  fast-text-table
   523.01x faster than text-table

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

Copy link

github-actions bot commented Jun 1, 2025

How to test

git clone -b chore/text-table https://github.com/D-Sketon/hexo.git
cd hexo
npm install
npm test

@coveralls
Copy link

coveralls commented Jun 1, 2025

Pull Request Test Coverage Report for Build 15371255298

Details

  • 4 of 4 (100.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 99.526%

Totals Coverage Status
Change from base Build 15158443601: 0.0%
Covered Lines: 9859
Relevant Lines: 9906

💛 - Coveralls

Copy link
Member

@SukkaW SukkaW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

text-table is slow due to how it doesn't use trimEnd.

@D-Sketon D-Sketon merged commit ac0338c into hexojs:master Jun 12, 2025
24 checks passed
@D-Sketon D-Sketon deleted the chore/text-table branch June 14, 2025 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants