<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="go version devel +f74ea6c Tue Jun 16 01:04:10 2015 +0000 windows/amd64"><pre class="notranslate"><code class="notranslate">go version devel +f74ea6c Tue Jun 16 01:04:10 2015 +0000 windows/amd64
</code></pre></div>
<div class="highlight highlight-source-go notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="func funA(a0, a1, b0, b1 uint32) uint32 {
    return ((a0&amp;0x12345678)&gt;&gt;2 + (a1&amp;0x12345678)&gt;&gt;3 + (b0&amp;0x12345678)&gt;&gt;4 + (b1&amp;0x12345678)&gt;&gt;5) +
        ((((a0 &amp; 0x87654321) + (a1 &amp; 0x87654321) + (b0 &amp; 0x87654321) + (b1 &amp; 0x87654321) + 0) &gt;&gt; 7) &amp; 0x87654321)
}

func funB(a0, a1, b0, b1 uint32) uint32 {
    const mask0, mask1 = 0x12345678, 0x87654321
    return ((a0&amp;mask0)&gt;&gt;2 + (a1&amp;mask0)&gt;&gt;3 + (b0&amp;mask0)&gt;&gt;4 + (b1&amp;mask0)&gt;&gt;5) +
        ((((a0 &amp; mask1) + (a1 &amp; mask1) + (b0 &amp; mask1) + (b1 &amp; mask1) + 0) &gt;&gt; 7) &amp; mask1)
}

func BenchmarkA(b *testing.B) {
    for i := 0; i &lt; b.N; i++ {
        for i := 0; i &lt; (1 &lt;&lt; 20); i++ {
            funA(1, 2, 3, 4)
        }
    }
}

func BenchmarkB(b *testing.B) {
    for i := 0; i &lt; b.N; i++ {
        for i := 0; i &lt; (1 &lt;&lt; 20); i++ {
            funB(1, 2, 3, 4)
        }
    }
}"><pre class="notranslate"><span class="pl-k">func</span> <span class="pl-en">funA</span>(<span class="pl-s1">a0</span>, <span class="pl-s1">a1</span>, <span class="pl-s1">b0</span>, <span class="pl-s1">b1</span> <span class="pl-smi">uint32</span>) <span class="pl-smi">uint32</span> {
    <span class="pl-k">return</span> ((<span class="pl-s1">a0</span><span class="pl-c1">&amp;</span><span class="pl-c1">0x12345678</span>)<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">2</span> <span class="pl-c1">+</span> (<span class="pl-s1">a1</span><span class="pl-c1">&amp;</span><span class="pl-c1">0x12345678</span>)<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">3</span> <span class="pl-c1">+</span> (<span class="pl-s1">b0</span><span class="pl-c1">&amp;</span><span class="pl-c1">0x12345678</span>)<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">4</span> <span class="pl-c1">+</span> (<span class="pl-s1">b1</span><span class="pl-c1">&amp;</span><span class="pl-c1">0x12345678</span>)<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">5</span>) <span class="pl-c1">+</span>
        ((((<span class="pl-s1">a0</span> <span class="pl-c1">&amp;</span> <span class="pl-c1">0x87654321</span>) <span class="pl-c1">+</span> (<span class="pl-s1">a1</span> <span class="pl-c1">&amp;</span> <span class="pl-c1">0x87654321</span>) <span class="pl-c1">+</span> (<span class="pl-s1">b0</span> <span class="pl-c1">&amp;</span> <span class="pl-c1">0x87654321</span>) <span class="pl-c1">+</span> (<span class="pl-s1">b1</span> <span class="pl-c1">&amp;</span> <span class="pl-c1">0x87654321</span>) <span class="pl-c1">+</span> <span class="pl-c1">0</span>) <span class="pl-c1">&gt;&gt;</span> <span class="pl-c1">7</span>) <span class="pl-c1">&amp;</span> <span class="pl-c1">0x87654321</span>)
}

<span class="pl-k">func</span> <span class="pl-en">funB</span>(<span class="pl-s1">a0</span>, <span class="pl-s1">a1</span>, <span class="pl-s1">b0</span>, <span class="pl-s1">b1</span> <span class="pl-smi">uint32</span>) <span class="pl-smi">uint32</span> {
    <span class="pl-k">const</span> <span class="pl-s1">mask0</span>, <span class="pl-s1">mask1</span> <span class="pl-c1">=</span> <span class="pl-c1">0x12345678</span>, <span class="pl-c1">0x87654321</span>
    <span class="pl-k">return</span> ((<span class="pl-s1">a0</span><span class="pl-c1">&amp;</span><span class="pl-s1">mask0</span>)<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">2</span> <span class="pl-c1">+</span> (<span class="pl-s1">a1</span><span class="pl-c1">&amp;</span><span class="pl-s1">mask0</span>)<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">3</span> <span class="pl-c1">+</span> (<span class="pl-s1">b0</span><span class="pl-c1">&amp;</span><span class="pl-s1">mask0</span>)<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">4</span> <span class="pl-c1">+</span> (<span class="pl-s1">b1</span><span class="pl-c1">&amp;</span><span class="pl-s1">mask0</span>)<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">5</span>) <span class="pl-c1">+</span>
        ((((<span class="pl-s1">a0</span> <span class="pl-c1">&amp;</span> <span class="pl-s1">mask1</span>) <span class="pl-c1">+</span> (<span class="pl-s1">a1</span> <span class="pl-c1">&amp;</span> <span class="pl-s1">mask1</span>) <span class="pl-c1">+</span> (<span class="pl-s1">b0</span> <span class="pl-c1">&amp;</span> <span class="pl-s1">mask1</span>) <span class="pl-c1">+</span> (<span class="pl-s1">b1</span> <span class="pl-c1">&amp;</span> <span class="pl-s1">mask1</span>) <span class="pl-c1">+</span> <span class="pl-c1">0</span>) <span class="pl-c1">&gt;&gt;</span> <span class="pl-c1">7</span>) <span class="pl-c1">&amp;</span> <span class="pl-s1">mask1</span>)
}

<span class="pl-k">func</span> <span class="pl-en">BenchmarkA</span>(<span class="pl-s1">b</span> <span class="pl-c1">*</span>testing.<span class="pl-smi">B</span>) {
    <span class="pl-k">for</span> <span class="pl-s1">i</span> <span class="pl-c1">:=</span> <span class="pl-c1">0</span>; <span class="pl-s1">i</span> <span class="pl-c1">&lt;</span> <span class="pl-s1">b</span>.<span class="pl-c1">N</span>; <span class="pl-s1">i</span><span class="pl-c1">++</span> {
        <span class="pl-k">for</span> <span class="pl-s1">i</span> <span class="pl-c1">:=</span> <span class="pl-c1">0</span>; <span class="pl-s1">i</span> <span class="pl-c1">&lt;</span> (<span class="pl-c1">1</span> <span class="pl-c1">&lt;&lt;</span> <span class="pl-c1">20</span>); <span class="pl-s1">i</span><span class="pl-c1">++</span> {
            <span class="pl-en">funA</span>(<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>, <span class="pl-c1">4</span>)
        }
    }
}

<span class="pl-k">func</span> <span class="pl-en">BenchmarkB</span>(<span class="pl-s1">b</span> <span class="pl-c1">*</span>testing.<span class="pl-smi">B</span>) {
    <span class="pl-k">for</span> <span class="pl-s1">i</span> <span class="pl-c1">:=</span> <span class="pl-c1">0</span>; <span class="pl-s1">i</span> <span class="pl-c1">&lt;</span> <span class="pl-s1">b</span>.<span class="pl-c1">N</span>; <span class="pl-s1">i</span><span class="pl-c1">++</span> {
        <span class="pl-k">for</span> <span class="pl-s1">i</span> <span class="pl-c1">:=</span> <span class="pl-c1">0</span>; <span class="pl-s1">i</span> <span class="pl-c1">&lt;</span> (<span class="pl-c1">1</span> <span class="pl-c1">&lt;&lt;</span> <span class="pl-c1">20</span>); <span class="pl-s1">i</span><span class="pl-c1">++</span> {
            <span class="pl-en">funB</span>(<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>, <span class="pl-c1">4</span>)
        }
    }
}</pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="BenchmarkA-4         500           3828382 ns/op
BenchmarkB-4         300           5467213 ns/op"><pre class="notranslate"><code class="notranslate">BenchmarkA-4         500           3828382 ns/op
BenchmarkB-4         300           5467213 ns/op
</code></pre></div>
<pre class="notranslate">The perf builders don't benchmark older commits:
<a href="http://build.golang.org/perf?page=100" rel="nofollow">http://build.golang.org/perf?page=100</a>
and perf-todo requests from builders fail:
2014/10/14 12:54:05 datastore: query has no more results
2014/10/14 12:55:04 datastore: query has no more results
2014/10/14 12:55:34 datastore: query has no more results
2014/10/14 12:56:04 datastore: query has no more results
2014/10/14 12:56:35 datastore: query has no more results

Looking at the symptoms it seems that Commit.Num's were manually updated, so that now
(1) PerfTodo entities contain invalid nums and (2) association between Commits and
CommitRun's is broken and (3) Commit nums jumped to 100'000, which created a huge hole
in CommitRun's which negatively affects the graphs UI (one could argue that benchmark
commits contain holes due to branches anyway, but small holes are OK and 100'000 is like
25 years of team's activity).

All these 3 points need to be repaired.</pre>