theckman / yacspin

Yet Another CLi Spinner; providing over 80 easy to use and customizable terminal spinners for multiple OSes
Apache License 2.0
434 stars 13 forks source link

Use a byte buffer to reduce number of write calls to stdout #44

Closed theckman closed 2 years ago

theckman commented 2 years ago

This change introduces a 2KB (growable) byte buffer, to sit in between the painting function(s) and stdout. Previously, as we were animating the spinner we would write the bytes directly to stdout as we were generating the animation.

This change makes it so that most of our writes are to an in-memory buffer, and then we only have one system call to write to the actaul terminal the contents of that buffer.

This should act like a bit of a frame buffer, so if if anyone was experiencing any sort of stutter, where they could see the cursor as the spinner was animated, I believe this should result in a smoother adnimation.

codecov[bot] commented 2 years ago

Codecov Report

Merging #44 (45ccc05) into master (a615053) will decrease coverage by 0.67%. The diff coverage is 55.88%.

:exclamation: Current head 45ccc05 differs from pull request most recent head a339dfc. Consider uploading reports for the commit a339dfc to get more accurate results Impacted file tree graph

@@            Coverage Diff             @@
##           master      #44      +/-   ##
==========================================
- Coverage   94.42%   93.75%   -0.68%     
==========================================
  Files           2        2              
  Lines         520      528       +8     
==========================================
+ Hits          491      495       +4     
- Misses         15       17       +2     
- Partials       14       16       +2     
Flag Coverage Δ
unittests 93.75% <55.88%> (-0.68%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
spinner.go 93.55% <55.88%> (-0.70%) :arrow_down:

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 39cf8f3...a339dfc. Read the comment docs.

theckman commented 2 years ago

When reviewing the report:

Everything is accounted for! No changes detected that need to be reviewed. -- @codecov

Sure, whatever you say...

theckman commented 2 years ago

@codecov is now removed from the project, so the comment above is no longer relevant. Merging!