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

(*Stream).Flush: reuse buffer after successful flush #440

Merged
merged 2 commits into from
Apr 29, 2020
Merged

(*Stream).Flush: reuse buffer after successful flush #440

merged 2 commits into from
Apr 29, 2020

Conversation

robfig
Copy link
Contributor

@robfig robfig commented Jan 18, 2020

Speeds up the example Stream usage in the benchmark by 20%

Rob Figueiredo added 2 commits January 17, 2020 16:50
Previously it would append to the end of the buffer instead of reusing the
now-free space.

Benchmark demonstrates the improvement, run with -benchtime=10s

    benchmark                                        old ns/op     new ns/op     delta
    Benchmark_encode_string_with_SetEscapeHTML-8     447           442           -1.12%
    Benchmark_jsoniter_large_file-8                  20998         21222         +1.07%
    Benchmark_json_large_file-8                      39593         40187         +1.50%
    Benchmark_stream_encode_big_object-8             10787         8611          -20.17%

    benchmark                                        old allocs     new allocs     delta
    Benchmark_encode_string_with_SetEscapeHTML-8     6              6              +0.00%
    Benchmark_jsoniter_large_file-8                  78             78             +0.00%
    Benchmark_json_large_file-8                      13             13             +0.00%
    Benchmark_stream_encode_big_object-8             31             0              -100.00%

    benchmark                                        old bytes     new bytes     delta
    Benchmark_encode_string_with_SetEscapeHTML-8     760           760           +0.00%
    Benchmark_jsoniter_large_file-8                  4920          4920          +0.00%
    Benchmark_json_large_file-8                      6640          6640          +0.00%
    Benchmark_stream_encode_big_object-8             10056         0             -100.00%

Fixes #438
@robfig robfig requested a review from taowen January 18, 2020 03:02
@codecov
Copy link

codecov bot commented Jan 18, 2020

Codecov Report

Merging #440 into master will increase coverage by 0.27%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #440      +/-   ##
==========================================
+ Coverage   86.46%   86.74%   +0.27%     
==========================================
  Files          41       41              
  Lines        5106     5106              
==========================================
+ Hits         4415     4429      +14     
+ Misses        555      541      -14     
  Partials      136      136
Impacted Files Coverage Δ
stream.go 90% <100%> (ø) ⬆️
reflect_struct_decoder.go 83.22% <0%> (+1.86%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 49c900e...91f4a64. Read the comment docs.

@AllenX2018 AllenX2018 merged commit 91f4a64 into json-iterator:master Apr 29, 2020
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.

2 participants