<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The ILNumerics Blog &#187; variance</title>
	<atom:link href="https://ilnumerics.net/blog/tag/variance/feed/" rel="self" type="application/rss+xml" />
	<link>https://ilnumerics.net/blog</link>
	<description>The Productivity Machine  &#124;  A fresh attempt for scientific computing  &#124;  http://ilnumerics.net</description>
	<lastBuildDate>Thu, 05 Dec 2024 09:09:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.41</generator>
	<item>
		<title>Quick and dirty tests and misleading results</title>
		<link>https://ilnumerics.net/blog/quick-and-dirty-tests-and-misleading-results/</link>
		<comments>https://ilnumerics.net/blog/quick-and-dirty-tests-and-misleading-results/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 17:36:56 +0000</pubDate>
		<dc:creator><![CDATA[haymo]]></dc:creator>
				<category><![CDATA[Comparison]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[memory bandwidth]]></category>
		<category><![CDATA[speed]]></category>
		<category><![CDATA[variance]]></category>

		<guid isPermaLink="false">http://ilnumerics.net/blog/?p=133</guid>
		<description><![CDATA[<p>Today this blog post popped up on my desktop. It describes a quick attempt to outperform the variance function of our friend library MathNet.Numerics by utilizing the Task Parallel Library from within F#. It obviously worked out &#8211; by a factor of 10! Since this seemed strange to me, I couldn&#8217;t resist to make my &#8230; <a href="https://ilnumerics.net/blog/quick-and-dirty-tests-and-misleading-results/" class="more-link">Continue reading <span class="screen-reader-text">Quick and dirty tests and misleading results</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/quick-and-dirty-tests-and-misleading-results/">Quick and dirty tests and misleading results</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Today <a href="http://viralfsharp.com/2012/02/25/outperforming-mathnet-with-task-parallel-library/trackback/">this blog post</a> popped up on my desktop. It describes a quick attempt to outperform the variance function of our friend library MathNet.Numerics by utilizing the Task Parallel Library from within F#. It obviously worked out &#8211; by a factor of 10! Since this seemed strange to me, I couldn&#8217;t resist to make my own (very quick and dirty) comparison. </p>
<p>The code: </p>
<pre class="brush: csharp; title: ; notranslate">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ILNumerics; 
using MathNet; 
using MathNet.Numerics.Statistics; 
using System.Diagnostics; 

namespace ConsoleApplication6 {
    class Program : ILMath {
        static void Main(string[] args) {
            long ms = 0; 
            int n = 10000000; 
            int it = 100; 

            ILArray&lt;double&gt; A = randn(1,n);
            Stopwatch sw = new Stopwatch(); 
            for (int i = 0; i &lt; it; i++) {
                sw.Restart(); 
                ILArray&lt;double&gt; B = var(A);
                sw.Stop(); 
                ms += sw.ElapsedMilliseconds; 
            }
            Console.WriteLine(&quot;ILNumerics needed: {0} ms&quot;,ms/(float)it); 
            
            double[] storage = A.ToArray();
            ms = 0; 
            for (int i = 0; i &lt; it; i++) {
                sw.Restart();
                double a = Statistics.Variance(storage); 
                sw.Stop();
                ms += sw.ElapsedMilliseconds;
            }
            Console.WriteLine(&quot;Mathnet.Numerics needed: {0} ms&quot;, ms / (float)it); 
            Console.ReadKey(); 
        }
    }
}
</pre>
<p>The result: </p>
<pre class="brush: csharp; title: ; notranslate">
ILNumerics needed: 101,87 ms
Mathnet.Numerics needed: 433,67 ms
</pre>
<p>So the performance of the MathNet implementation is actually not too bad. ILNumerics does parallelize the var() function (the test run on a dual core) and uses unsafe pointer optimized code for the iteration. So a factor of 4 over MathNet is reasonable. I suppose, the speedup of 10 in the referenced F# blog post is more a measure of memory bandwith. The test there have not been repeatedly run and so it appears, the given implementation is advantageous in terms of memory accesses. Possibly some prefetch of cachelines or similar is going on. </p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/quick-and-dirty-tests-and-misleading-results/">Quick and dirty tests and misleading results</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://ilnumerics.net/blog/quick-and-dirty-tests-and-misleading-results/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
