claunia / plist-cil

C#/.NET parser for Apple and GnuStep Property List (aka plist), based on Java's dd-plist
Other
54 stars 17 forks source link

Use cached values for ASCII, UTF8 and UTF16 encoding #42

Closed qmfrederik closed 6 years ago

qmfrederik commented 6 years ago

Calling Encoding.GetEncoding is surprisingly expensive, so use cached properties instead. 11.8% improvement on Windows and 22% improvement on Linux.

qmfrederik commented 6 years ago

Windows

Before

Method Mean Error StdDev Gen 0 Gen 1 Allocated
ReadLargePropertylistTest 2.270 ms 0.0462 ms 0.0974 ms 175.7813 85.9375 1.06 MB

After

Method Mean Error StdDev Median Gen 0 Gen 1 Allocated
ReadLargePropertylistTest 2.001 ms 0.0547 ms 0.1525 ms 1.943 ms 175.7813 85.9375 1.06 MB

Linux

Before

Method Mean Error StdDev Gen 0 Gen 1 Allocated
ReadLargePropertylistTest 4.881 ms 0.0515 ms 0.0482 ms 164.0625 78.1250 1.06 MB

After

Method Mean Error StdDev Gen 0 Gen 1 Allocated
ReadLargePropertylistTest 3.807 ms 0.0710 ms 0.0629 ms 171.8750 85.9375 1.06 MB
qmfrederik commented 6 years ago

@claunia Any chance you'll be able to look at these PRs in the near future? Thanks!

claunia commented 6 years ago

@qmfrederik when have I failed you!? At most you have to wait til weekend. Oh look, WEEKEND!

qmfrederik commented 6 years ago

@claunia Thanks! And enjoy the weekend! 😄