Skip to content
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

Make indent faster by preallocating the output string #354

Merged
merged 2 commits into from
May 13, 2021

Commits on May 13, 2021

  1. Add simple benchmark for indent

    On my system, it takes just under 2 microseconds to indent the 50
    lines in the ~2 KB text:
    
        % cargo criterion --bench indent
        indent                  time:   [1.8829 us 1.8891 us 1.8948 us]
    mgeisler committed May 13, 2021
    Configuration menu
    Copy the full SHA
    dc8928b View commit details
    Browse the repository at this point in the history
  2. Preallocate output string for indent

    This makes the function about 20% faster:
    
        % cargo criterion --bench indent
        indent                  time:   [1.4647 us 1.4670 us 1.4698 us]
                                change: [-23.426% -22.816% -22.328%] (p = 0.00 < 0.05)
                                Performance has improved.
    mgeisler committed May 13, 2021
    Configuration menu
    Copy the full SHA
    19bb2ef View commit details
    Browse the repository at this point in the history