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

Optimize Sugar logger for calls with a single string arg #913

Merged
merged 1 commit into from Feb 8, 2021

Commits on Feb 5, 2021

  1. Optimize Sugar logger for calls with a single string arg

    Currently, the Sugar logger uses fmt.Sprint in all cases when the
    template is empty. However, this call is unnecessary if there's
    a single string type argument, as we can use it directly.
    
    With this optimization, we reduce the cost and avoid an unnecessary
    alloc:
    ```
    > benchcmp pre post
    benchmark                         old ns/op     new ns/op     delta
    BenchmarkSugarSingleStrArg-10     636           570           -10.38%
    
    benchmark                         old allocs     new allocs     delta
    BenchmarkSugarSingleStrArg-10     1              0              -100.00%
    ```
    prashantv committed Feb 5, 2021
    Copy the full SHA
    9382aa4 View commit details
    Browse the repository at this point in the history