<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="https://shazwazza.com/rss/xslt"?>
<rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Shazwazza</title>
    <link>https://shazwazza.com/</link>
    <description>My blog which is pretty much just all about coding</description>
    <generator>Articulate, blogging built on Umbraco</generator>
    <image>
      <url>/media/0libq25y/frog.png?rmode=max&amp;v=1da0e911f4e6890</url>
      <title>Shazwazza</title>
      <link>https://shazwazza.com/</link>
    </image>
    <item>
      <guid isPermaLink="false">1231</guid>
      <link>https://shazwazza.com/post/benchmarking-performance-of-your-code-between-release-versions/</link>
      <category>ASP.Net</category>
      <title>Benchmarking performance of your code between release versions</title>
      <description>&lt;p&gt;A while ago in 2016 I posted a &lt;a rel="noopener" href="https://github.com/dotnet/BenchmarkDotNet/issues/290" target="_blank"&gt;question&lt;/a&gt; on the &lt;a rel="noopener" href="https://github.com/dotnet/BenchmarkDotNet" target="_blank"&gt;BenchmarkDotNet&lt;/a&gt; repository about an official way to run benchmarks between Nuget releases. In 2018 I managed to find some time and with the with the help of &lt;a rel="noopener" href="https://github.com/adamsitnik" target="_blank"&gt;Adam Sitnik&lt;/a&gt; (one of the project’s maintainers), was able to &lt;a rel="noopener" href="https://github.com/dotnet/BenchmarkDotNet/pull/922" target="_blank"&gt;make that work&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;I won’t go into detail about what BenchmarkDotNet is, but it’s a brilliant way to accurately run benchmarks against your code to see how it performs, how much memory is being used, etc…&lt;/p&gt;
&lt;p&gt;With this new feature you can now easily see how your code changes effect performance between your releases.&lt;/p&gt;
&lt;h2&gt;Show me the code&lt;/h2&gt;
&lt;p&gt;Making this work is quite easy and there’s a &lt;a rel="noopener" href="https://github.com/dotnet/BenchmarkDotNet/blob/master/samples/BenchmarkDotNet.Samples/IntroNuGet.cs" target="_blank"&gt;quick start code snippet&lt;/a&gt; in the repo already. For the example below I’ll use &lt;a rel="noopener" href="https://sixlabors.com/projects/imagesharp/" target="_blank"&gt;ImageSharp&lt;/a&gt; as the library to be tested and we’ll see how well &lt;a rel="noopener" href="https://twitter.com/James_M_South" target="_blank"&gt;James&lt;/a&gt; and his team is doing with regards to improving it’s JPEG decoding performance.&lt;/p&gt;
&lt;pre class="lang-csharp"&gt;&lt;code&gt;
[Config(typeof(Config))]
public class ImageTests
{
    private static readonly string _filePath = @"C:\temp\test.jpg";

    private class Config : ManualConfig
    {
        public Config()
        {
            var baseJob = Job.MediumRun.With(CsProjCoreToolchain.Current.Value);
            Add(baseJob.WithNuGet("SixLabors.ImageSharp", "1.0.0-beta0006").WithId("1.0.0-beta0006"));
            Add(baseJob.WithNuGet("SixLabors.ImageSharp", "1.0.0-beta0005").WithId("1.0.0-beta0005"));
            Add(baseJob.WithNuGet("SixLabors.ImageSharp", "1.0.0-beta0004").WithId("1.0.0-beta0004"));
        }
    }

    [Benchmark]
    public Size LoadJpg()
    {
        using (var img = Image.Load(_filePath))
        {
            var size = img.Size();
            return size;
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The code above should seem pretty straightforward. It’s just setting up 3 BenchmarkDotNet jobs, each using a different version of the SixLabors.ImageSharp Nuget package. Then the actual benchmark test is loading in a JPEG extracting it’s size and returning it.&lt;/p&gt;
&lt;p&gt;Running the benchmark is like running any other BenchmarkDotNet test, for example in a console app:&lt;/p&gt;
&lt;pre class="lang-csharp"&gt;&lt;code&gt;
class Program
{
    static void Main(string[] args)
    {   
        var summary = BenchmarkRunner.Run();
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;The results&lt;/h2&gt;
&lt;table border="0"&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Job&lt;/th&gt;
&lt;th&gt;NuGetReferences&lt;/th&gt;
&lt;th&gt;Mean&lt;/th&gt;
&lt;th&gt;Error&lt;/th&gt;
&lt;th&gt;StdDev&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;LoadJpg&lt;/td&gt;
&lt;td&gt;1.0.0-beta0004&lt;/td&gt;
&lt;td&gt;SixLabors.ImageSharp 1.0.0-beta0004&lt;/td&gt;
&lt;td&gt;297.5 ms&lt;/td&gt;
&lt;td&gt;142.8 ms&lt;/td&gt;
&lt;td&gt;7.827 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LoadJpg&lt;/td&gt;
&lt;td&gt;1.0.0-beta0005&lt;/td&gt;
&lt;td&gt;SixLabors.ImageSharp 1.0.0-beta0005&lt;/td&gt;
&lt;td&gt;202.9 ms&lt;/td&gt;
&lt;td&gt;466.6 ms&lt;/td&gt;
&lt;td&gt;25.577 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LoadJpg&lt;/td&gt;
&lt;td&gt;1.0.0-beta0006&lt;/td&gt;
&lt;td&gt;SixLabors.ImageSharp 1.0.0-beta0006&lt;/td&gt;
&lt;td&gt;148.8 ms&lt;/td&gt;
&lt;td&gt;107.8 ms&lt;/td&gt;
&lt;td&gt;5.910 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Looks good! from the beta0004 release to the beta0006 release there’s almost twice the performance boost.&lt;/p&gt;
&lt;h2&gt;API Surface Area&lt;/h2&gt;
&lt;p&gt;There is one caveat though… In order to run these tests between versions of your library, the same API surface area will need to exist otherwise you’ll get exceptions when running the benchmarks. This is the reason why versions beta0001 –&amp;gt; beta0003 are not included in the jobs listed above. Its because in the older versions either the APIs were different or the namespaces were different.&lt;/p&gt;
&lt;p&gt;It is possible to work around this but you’d need to use some ugly reflection to do it and then you need to be careful that you are not testing the reflection performance hit either.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Now you should have a pretty easy way to know how the performance of your library is changing between versions. Happy coding!&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:09:17 Z</pubDate>
      <a10:updated>2023-03-23T15:09:17Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1192</guid>
      <link>https://shazwazza.com/post/umbraco-41-benchmarks-part-2-back-office-database-queries/</link>
      <category>Umbraco</category>
      <title>Umbraco 4.1 Benchmarks Part 2 (Back Office Database Queries)</title>
      <description>&lt;div class="imported-post"&gt;This post was imported from FARMCode.org which has been discontinued. These posts now exist here as an archive. They may contain broken links and images.&lt;/div&gt;This is part 2 in a series of Umbraco 4.1 benchmarks created by various members of the core team in the lead up to launch. See &lt;a href="http://farmcode.org/post/2010/04/19/Umbraco-41-Benchmarks-Part-1-%28Do-Over%29.aspx"&gt;Part 1 here&lt;/a&gt; on request/response peformance in the Umbraco back office.  &lt;p&gt;This benchmark report looks at the data layer improvements in 4.1 by comparing query counts in 4.1 to 4.0.3. Not only has the data layer improved but there’s been significant improvements in the consumption of the data layer API made by many of the 4.1 pages and controls.&lt;/p&gt; &lt;p&gt;The stats below are represented as a percentage of the total calls of 4.0.3 where the number of queries in 4.0.3 are 100% and the number of queries in 4.1 are a percentage in relation to this. These results are based on the procedures listed at the bottom of this post and on averages run over 3 separate trials.&lt;/p&gt; &lt;style&gt;


















.stats th {background-color:#ffffcc;color:black;}
.stats td, .stats th {
border-top:solid 1px black;
border-right:solid 1px black;
border-top:solid 1px black;
}
.stats td.first, .stats th.first {
border-left:solid 1px black;
}
.stats tr.bottom td, .stats td.bottom {
border-bottom:solid 1px black;
}
.stats tr.one { background-color:#ededed;}
.stats tr.two { background-color:#dcdcdc;}
.stats tr.three { background-color:#ededed;}
.stats tr.four {background-color:#d6f5f5;}&lt;/style&gt;  &lt;table class="stats" cellspacing="0" cellpadding="2" width="470"&gt; &lt;tbody&gt; &lt;tr class="one"&gt; &lt;th class="first" valign="top" width="326"&gt;Step&lt;/td&gt; &lt;/th&gt; &lt;th valign="top" width="72"&gt;4.0.3&lt;/td&gt; &lt;/th&gt; &lt;th valign="top" width="70"&gt;4.1.0&lt;/td&gt; &lt;/tr&gt;&lt;/th&gt;&lt;/tr&gt; &lt;tr class="two"&gt; &lt;td class="first" valign="top" width="326"&gt;Login&lt;/td&gt; &lt;td valign="top" width="72"&gt;100%&lt;/td&gt; &lt;td valign="top" width="70"&gt;68%&lt;/td&gt;&lt;/tr&gt; &lt;tr class="one"&gt; &lt;td class="first" valign="top" width="326"&gt;Expand all Content nodes&lt;/td&gt; &lt;td valign="top" width="72"&gt;100%&lt;/td&gt; &lt;td valign="top" width="70"&gt;23%&lt;/td&gt;&lt;/tr&gt; &lt;tr class="one"&gt; &lt;td class="first" valign="top" width="326"&gt;Edit Home node&lt;/td&gt; &lt;td valign="top" width="72"&gt;100%&lt;/td&gt; &lt;td valign="top" width="70"&gt;49%&lt;/td&gt;&lt;/tr&gt; &lt;tr class="two"&gt; &lt;td class="first" valign="top" width="326"&gt;Publishing Home node&lt;/td&gt; &lt;td valign="top" width="72"&gt;100%&lt;/td&gt; &lt;td valign="top" width="70"&gt;55%&lt;/td&gt;&lt;/tr&gt; &lt;tr class="one"&gt; &lt;td class="first" valign="top" width="326"&gt;Edit About Umbraco node&lt;/td&gt; &lt;td valign="top" width="72"&gt;100%&lt;/td&gt; &lt;td valign="top" width="70"&gt;49%&lt;/td&gt;&lt;/tr&gt; &lt;tr class="two"&gt; &lt;td class="first" valign="top" width="326"&gt;Go to Settings App&lt;/td&gt; &lt;td valign="top" width="72"&gt;100%&lt;/td&gt; &lt;td valign="top" width="70"&gt;100%&lt;/td&gt;&lt;/tr&gt; &lt;tr class="one"&gt; &lt;td class="first" valign="top" width="326"&gt;Expand Document types tree&lt;/td&gt; &lt;td valign="top" width="72"&gt;100%&lt;/td&gt; &lt;td valign="top" width="70"&gt;100%&lt;/td&gt;&lt;/tr&gt; &lt;tr class="two"&gt; &lt;td class="first" valign="top" width="326"&gt;Edit Home document type&lt;/td&gt; &lt;td valign="top" width="72"&gt;100%&lt;/td&gt; &lt;td valign="top" width="70"&gt;61%&lt;/td&gt;&lt;/tr&gt; &lt;tr class="one"&gt; &lt;td class="first" valign="top" width="326"&gt;Save Home document type&lt;/td&gt; &lt;td valign="top" width="72"&gt;100%&lt;/td&gt; &lt;td valign="top" width="70"&gt;67%&lt;/td&gt;&lt;/tr&gt; &lt;tr class="two"&gt; &lt;td class="first" valign="top" width="326"&gt;Go to Media app&lt;/td&gt; &lt;td valign="top" width="72"&gt;100%&lt;/td&gt; &lt;td valign="top" width="70"&gt;50%&lt;/td&gt;&lt;/tr&gt; &lt;tr class="one"&gt; &lt;td class="first" valign="top" width="326"&gt;Create new folder labeled ‘Test’&lt;/td&gt; &lt;td valign="top" width="72"&gt;100%&lt;/td&gt; &lt;td valign="top" width="70"&gt;88%&lt;/td&gt;&lt;/tr&gt; &lt;tr class="two"&gt; &lt;td class="first" valign="top" width="326"&gt;Create new image under new ‘Test’ folder labeled ‘test1’&lt;/td&gt; &lt;td valign="top" width="72"&gt;100%&lt;/td&gt; &lt;td valign="top" width="70"&gt;64%&lt;/td&gt;&lt;/tr&gt; &lt;tr class="one"&gt; &lt;td class="first" valign="top" width="326"&gt;Upload new image file to ‘test1’ and save the node&lt;/td&gt; &lt;td valign="top" width="72"&gt;100%&lt;/td&gt; &lt;td valign="top" width="70"&gt;49%&lt;/td&gt;&lt;/tr&gt; &lt;tr class="two"&gt; &lt;td class="first" valign="top" width="326"&gt;Go to Content app (and in the case of 4.0.3, expand the tree and select the About Umbraco node since in 4.1 this will already be selected and loaded)&lt;/td&gt; &lt;td valign="top" width="72"&gt;100%&lt;/td&gt; &lt;td valign="top" width="70"&gt;41%&lt;/td&gt;&lt;/tr&gt; &lt;tr class="one"&gt; &lt;td class="first" valign="top" width="326"&gt;Edit Home node&lt;/td&gt; &lt;td valign="top" width="72"&gt;100%&lt;/td&gt; &lt;td valign="top" width="70"&gt;43%&lt;/td&gt;&lt;/tr&gt; &lt;tr class="two"&gt; &lt;td class="first" valign="top" width="326"&gt;Add ‘test1’ image to the ‘Text’ WYSIWYG property with the image picker and Publish node&lt;/td&gt; &lt;td class="first" valign="top" width="72"&gt;100%&lt;/td&gt; &lt;td valign="top" width="70"&gt;49%&lt;/td&gt;&lt;/tr&gt; &lt;tr class="four"&gt; &lt;td class="first" valign="top" width="326"&gt;Average of averages above&lt;/td&gt; &lt;td valign="top" width="72"&gt;&amp;nbsp;&lt;/td&gt; &lt;td valign="top" width="70"&gt;60%&lt;/td&gt;&lt;/tr&gt; &lt;tr class="four bottom"&gt; &lt;td class="first" valign="top" width="326"&gt;Complete run through of the above steps&lt;/td&gt; &lt;td valign="top" width="72"&gt;100%&lt;/td&gt; &lt;td valign="top" width="70"&gt;66%&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;So based on averages, Umbraco 4.1 is looking to have around &lt;font size="4"&gt;&lt;strong&gt;40% less&lt;/strong&gt; &lt;/font&gt;queries made than 4.0.3!!! Thats HUGE! &lt;/p&gt; &lt;p&gt;The following steps were taken on each trial of the above steps:&lt;/font&gt;&lt;/em&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;New instances of both 4.0.3 and 4.1  &lt;li&gt;Install CWS package on both instances  &lt;li&gt;Log out of both instances  &lt;li&gt;Bump web.config for both instances (clear out all data cache)  &lt;li&gt;Use SQL Profiler to determine query counts for each step listed above &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Also, SQL debugging has been added to 4.1 for MS SQL instances. If you compile the source in Debug mode you can get the SQL command output by adding a trace listener to your web.config. Underneath the configuration node you can add this xml block:&lt;/p&gt;&lt;pre&gt;&amp;lt;system.diagnostics&amp;gt;
	&amp;lt;trace autoflush="true"&amp;gt;
	  &amp;lt;listeners&amp;gt;
		&amp;lt;add name="SqlListener" 
			type="System.Diagnostics.TextWriterTraceListener" 
			initializeData="trace.log" /&amp;gt;
	  &amp;lt;/listeners&amp;gt;
	&amp;lt;/trace&amp;gt;
&amp;lt;/system.diagnostics&amp;gt;
&lt;/pre&gt;
&lt;p&gt;This will create a trace.log file in the root of your web app SQL debugging.&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:14 Z</pubDate>
      <a10:updated>2023-03-23T15:08:14Z</a10:updated>
    </item>
  </channel>
</rss>