statiqdev / Statiq.Framework

A flexible and extensible static content generation framework for .NET.
https://statiq.dev/framework
MIT License
425 stars 74 forks source link

Optimizing Replace method in MemoryExtensions #229

Closed phil-scott-78 closed 2 years ago

phil-scott-78 commented 2 years ago

I was taking a look at some of the perf and poked around here. With 4,000 files the little things are starting to add up. Did two main things

Took the number of times the call to the Span getter and the indexer were being called from 200 million times down to 5 million. This helps out a bit with the constructor knocking the total amount of time spent building those up on my machine from 18s down to 5.

Before

image

After

image

CLAassistant commented 2 years ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

phil-scott-78 commented 2 years ago

Went to bed and thought to myself - "wait a second, those were all getters...I bet I had it on Debug mode like a moron."

Did a second test and sure enough, compiler takes care of those things for me. Disregard!