<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://axel.vanabkou.de/feed.xml" rel="self" type="application/atom+xml" /><link href="https://axel.vanabkou.de/" rel="alternate" type="text/html" /><updated>2026-05-04T21:19:35+00:00</updated><id>https://axel.vanabkou.de/feed.xml</id><title type="html">The Lost Harddrive</title><subtitle>Blogs about</subtitle><entry><title type="html">Code Benchmarking</title><link href="https://axel.vanabkou.de/posts/benchmarking" rel="alternate" type="text/html" title="Code Benchmarking" /><published>2025-07-12T00:00:00+00:00</published><updated>2025-07-12T00:00:00+00:00</updated><id>https://axel.vanabkou.de/posts/benchmarking</id><content type="html" xml:base="https://axel.vanabkou.de/posts/benchmarking"><![CDATA[<h2 id="chapter-0-hardware--software">Chapter 0: Hardware &amp; Software</h2>
<h1 id="what-do-we-have">What do we have??</h1>
<p>TODO: Intro</p>
<ul>
  <li>Make your experiments reproducable and gain insights in differences
  in reproduced results from others.</li>
</ul>

<p>TODO: How to get hardware info</p>
<ul>
  <li>lscpu (clock speed, architecture)</li>
  <li>lshw  (cache/ram info)</li>
</ul>

<p>TODO: Latency of instructions</p>
<ul>
  <li>Arithmatic instructions low latency</li>
  <li>Memory reads and writes more complex
    <ul>
      <li>(use comparison of real time adding from ComputerFile: 
 https://www.youtube.com/watch?v=PpaQrzoDW2I)</li>
    </ul>
  </li>
</ul>

<p>TODO: How to get software info</p>
<ul>
  <li>gcc -v</li>
</ul>

<p>TODO: Provide scripts on how to get this information</p>

<h2 id="chapter-1-scoping">Chapter 1: Scoping</h2>
<h1 id="what-do-we-want-to-know">What do we want to know?</h1>

<p>What do we want to measure?
Why do we want to measure it?
Do we need to measure it?
Main takeaway: do not benchmark everything!
(talk about tools like valgrind etc)</p>

<p>TODO: Make Flowchart ending in benchmark or don’t benchmark.</p>

<h2 id="chapter-2-theoretical-speed">Chapter 2: Theoretical speed</h2>
<h1 id="what-do-we-expect">What do we expect??</h1>

<p>TODO: Intro</p>
<ul>
  <li>Get insights on how an algorithm performs relative to theory</li>
</ul>

<p>TODO: Introduce Complexity</p>
<ul>
  <li>Big O theoretical concept
    <ul>
      <li>Time complexity</li>
      <li>Space complexity</li>
    </ul>
  </li>
  <li>Big O practical concept
    <ul>
      <li>A for loop where we do one multiplication and one addition:</li>
    </ul>
  </li>
</ul>

<figure class="highlight"><pre><code class="language-c" data-lang="c"><span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">r1</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">r1</span> <span class="o">&lt;</span> <span class="n">LEN_R1</span><span class="p">;</span> <span class="n">r1</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>               <span class="cm">/* n^1*add + n^1*lt  */</span>
    <span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">c2</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">c2</span> <span class="o">&lt;</span> <span class="n">LEN_C2</span><span class="p">;</span> <span class="n">c2</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>           <span class="cm">/* n^2*add + n^2*lt  */</span>
        <span class="n">res</span><span class="p">[</span><span class="n">r1</span><span class="p">][</span><span class="n">c2</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
        <span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">c1</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">c1</span> <span class="o">&lt;</span> <span class="n">LEN_C1</span><span class="p">;</span> <span class="n">c1</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>       <span class="cm">/* n^3*add + n^3*lt  */</span> 
            <span class="n">res</span><span class="p">[</span><span class="n">r1</span><span class="p">][</span><span class="n">c2</span><span class="p">]</span> <span class="o">+=</span> <span class="n">m1</span><span class="p">[</span><span class="n">r1</span><span class="p">][</span><span class="n">c1</span><span class="p">]</span> <span class="o">*</span> <span class="n">m2</span><span class="p">[</span><span class="n">c1</span><span class="p">][</span><span class="n">c2</span><span class="p">];</span> <span class="cm">/* n^3*add + n^3*mul */</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="p">}</span></code></pre></figure>

<p>NOTE: assume the compiler does not optimize anything.</p>

<figure class="highlight"><pre><code class="language-markdown" data-lang="markdown">Time: O(add x (2n^3+n^2+n^1) + lt x (n^3+n^2+n^1)+ mul x n^3)</code></pre></figure>

<p>TODO: Calculate theoretical speed
TODO: Simple case study</p>
<ul>
  <li>Why is this off?
    <ul>
      <li>optimizations of the compiler</li>
      <li>memory reads and writes</li>
    </ul>
  </li>
</ul>

<h2 id="chapter-3-validity">Chapter 3: Validity</h2>
<h1 id="what-are-we-measuring">What are we measuring?</h1>

<p>TODO: Testing with pre and post conditions</p>
<ul>
  <li>Have these be the same when comparing versions or programs.
This is to ensure we dont compare apples with oranges.</li>
</ul>

<p>TODO: Use Scoping</p>
<ul>
  <li>Find a subsection of code that answers the question that has been Scoped</li>
</ul>

<h2 id="sources">SOURCES</h2>

<p><a href="https://en.algorithmica.org/hpc/">algorithmica: Algorithms for Modern Hardware</a></p>

<p><a href="https://people.freebsd.org/~lstewart/articles/cpumemory.pdf">Ulrich Drepper: What Every Programmer Should Know About Memory</a></p>]]></content><author><name></name></author><category term="roadmap" /><category term="benchmarking" /><category term="cpu-performance" /><category term="caches" /><summary type="html"><![CDATA[Chapter 0: Hardware &amp; Software What do we have?? TODO: Intro Make your experiments reproducable and gain insights in differences in reproduced results from others.]]></summary></entry></feed>