Skip to content

Instantly share code, notes, and snippets.

@JimBobSquarePants
Last active December 17, 2016 10:59
Show Gist options
  • Save JimBobSquarePants/3c33f4709597d402335965fe94a64127 to your computer and use it in GitHub Desktop.
Save JimBobSquarePants/3c33f4709597d402335965fe94a64127 to your computer and use it in GitHub Desktop.
Performance improvements in the gif encoder

WIP improvements made so far in the gif encoder. All the time/memory usage is in the OctreeQuantizer.cs I don't know what quantizer System.Drawing uses (Most likely a fixed palette with pre-dithering) but the quality difference is incomparable.

It'll probably take a better mind than mine to bring the memory usage in the quantizer down further.

P.S ArrayPool<T> rocks!!!

Before

Method Mean StdDev Scaled Scaled-StdDev Gen 0 Allocated
'System.Drawing Gif' 13.5993 ms 0.4928 ms 1.00 0.00 - 1.12 MB
'ImageSharp Gif' 75.0405 ms 2.1495 ms 5.52 0.24 2645.8333 17.96 MB

After

Method Mean StdErr StdDev Scaled Scaled-StdDev Gen 0 Gen 1 Allocated
'System.Drawing Gif' 14.7249 ms 0.1580 ms 0.9866 ms 1.00 0.00 - - 1.12 MB
'ImageSharp Gif' 75.0355 ms 0.4332 ms 1.6777 ms 5.12 0.34 1187.5000 312.5000 9.22 MB

New After Massive improvement after removing boxing allocations.

Method Mean StdDev Scaled Scaled-StdDev Allocated
'System.Drawing Gif' 20.2133 ms 1.1400 ms 1.00 0.00 1.12 MB
'ImageSharp Gif' 86.3056 ms 0.8807 ms 4.28 0.23 2.74 MB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment