<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[166667] trunk/PerformanceTests</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/166667">166667</a></dd>
<dt>Author</dt> <dd>ggaren@apple.com</dd>
<dt>Date</dt> <dd>2014-04-02 14:38:49 -0700 (Wed, 02 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Let's benchmark malloc
https://bugs.webkit.org/show_bug.cgi?id=131118

Reviewed by Mark Hahnenberg.

I want to replace fastMalloc with something faster (fasterMalloc?).
I wrote these benchmarks to test / drive development.

* MallocBench: Added.
* MallocBench/MallocBench: Added.
* MallocBench/MallocBench.xcodeproj: Added.
* MallocBench/MallocBench.xcodeproj/project.pbxproj: Added.
* MallocBench/MallocBench/Benchmark.cpp: Added.
(allocateHeap):
(deallocateHeap):
(Benchmark::Benchmark):
(Benchmark::printBenchmarks):
(Benchmark::runOnce):
(Benchmark::run):
(Benchmark::printReport):
(Benchmark::currentTimeMS):
(Benchmark::currentMemoryBytes):
* MallocBench/MallocBench/Benchmark.h: Added.
(Benchmark::Memory::Memory):
(Benchmark::Memory::operator-):
(Benchmark::isValid):
* MallocBench/MallocBench/CPUCount.cpp: Added.
(cpuCount):
* MallocBench/MallocBench/CPUCount.h: Added.
* MallocBench/MallocBench/CommandLine.cpp: Added.
(CommandLine::printUsage):
* MallocBench/MallocBench/CommandLine.h: Added.
(CommandLine::isValid):
(CommandLine::benchmarkName):
(CommandLine::isParallel):
(CommandLine::heapSize):
(CommandLine::measureHeap):
* MallocBench/MallocBench/Interpreter.cpp: Added.
(Interpreter::Interpreter):
(Interpreter::~Interpreter):
(Interpreter::run):
* MallocBench/MallocBench/Interpreter.h: Added.
* MallocBench/MallocBench/balloon.cpp: Added.
(benchmark_balloon):
* MallocBench/MallocBench/balloon.h: Added.
* MallocBench/MallocBench/big.cpp: Added.
(benchmark_big):
* MallocBench/MallocBench/big.h: Added.
* MallocBench/MallocBench/churn.cpp: Added.
(HeapDouble::operator new):
(HeapDouble::operator delete):
(HeapDouble::HeapDouble):
(HeapDouble::operator+=):
(benchmark_churn):
* MallocBench/MallocBench/churn.h: Added.
* MallocBench/MallocBench/crash.ops: Added.
* MallocBench/MallocBench/facebook.cpp: Added.
(benchmark_facebook):
* MallocBench/MallocBench/facebook.h: Added.
* MallocBench/MallocBench/facebook.ops: Added.
* MallocBench/MallocBench/fragment.cpp: Added.
(validate):
(benchmark_fragment):
(benchmark_fragment_iterate):
* MallocBench/MallocBench/fragment.h: Added.
* MallocBench/MallocBench/list.cpp: Added.
(benchmark_list_allocate):
(benchmark_list_traverse):
* MallocBench/MallocBench/list.h: Added.
* MallocBench/MallocBench/main.cpp: Added.
(main):
* MallocBench/MallocBench/mbmalloc.cpp: Added.
* MallocBench/MallocBench/mbmalloc.h: Added.
* MallocBench/MallocBench/medium.cpp: Added.
(benchmark_medium):
* MallocBench/MallocBench/medium.h: Added.
* MallocBench/MallocBench/message.cpp: Added.
(benchmark_message_one):
(benchmark_message_many):
* MallocBench/MallocBench/message.h: Added.
* MallocBench/MallocBench/realloc.cpp: Added.
(benchmark_realloc):
* MallocBench/MallocBench/realloc.h: Added.
* MallocBench/MallocBench/tree.cpp: Added.
(benchmark_tree_allocate):
(benchmark_tree_traverse):
(benchmark_tree_churn):
* MallocBench/MallocBench/tree.h: Added.
* MallocBench/run-malloc-benchmarks: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkPerformanceTestsChangeLog">trunk/PerformanceTests/ChangeLog</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/PerformanceTests/MallocBench/</li>
<li>trunk/PerformanceTests/MallocBench/MallocBench/</li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchBenchmarkcpp">trunk/PerformanceTests/MallocBench/MallocBench/Benchmark.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchBenchmarkh">trunk/PerformanceTests/MallocBench/MallocBench/Benchmark.h</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchCPUCountcpp">trunk/PerformanceTests/MallocBench/MallocBench/CPUCount.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchCPUCounth">trunk/PerformanceTests/MallocBench/MallocBench/CPUCount.h</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchCommandLinecpp">trunk/PerformanceTests/MallocBench/MallocBench/CommandLine.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchCommandLineh">trunk/PerformanceTests/MallocBench/MallocBench/CommandLine.h</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchInterpretercpp">trunk/PerformanceTests/MallocBench/MallocBench/Interpreter.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchInterpreterh">trunk/PerformanceTests/MallocBench/MallocBench/Interpreter.h</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchballooncpp">trunk/PerformanceTests/MallocBench/MallocBench/balloon.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchballoonh">trunk/PerformanceTests/MallocBench/MallocBench/balloon.h</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchbigcpp">trunk/PerformanceTests/MallocBench/MallocBench/big.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchbigh">trunk/PerformanceTests/MallocBench/MallocBench/big.h</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchchurncpp">trunk/PerformanceTests/MallocBench/MallocBench/churn.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchchurnh">trunk/PerformanceTests/MallocBench/MallocBench/churn.h</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchfacebookcpp">trunk/PerformanceTests/MallocBench/MallocBench/facebook.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchfacebookh">trunk/PerformanceTests/MallocBench/MallocBench/facebook.h</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchfacebookops">trunk/PerformanceTests/MallocBench/MallocBench/facebook.ops</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchfragmentcpp">trunk/PerformanceTests/MallocBench/MallocBench/fragment.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchfragmenth">trunk/PerformanceTests/MallocBench/MallocBench/fragment.h</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchlistcpp">trunk/PerformanceTests/MallocBench/MallocBench/list.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchlisth">trunk/PerformanceTests/MallocBench/MallocBench/list.h</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchmaincpp">trunk/PerformanceTests/MallocBench/MallocBench/main.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchmbmalloccpp">trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchmbmalloch">trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.h</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchmediumcpp">trunk/PerformanceTests/MallocBench/MallocBench/medium.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchmediumh">trunk/PerformanceTests/MallocBench/MallocBench/medium.h</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchmessagecpp">trunk/PerformanceTests/MallocBench/MallocBench/message.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchmessageh">trunk/PerformanceTests/MallocBench/MallocBench/message.h</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchrealloccpp">trunk/PerformanceTests/MallocBench/MallocBench/realloc.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchrealloch">trunk/PerformanceTests/MallocBench/MallocBench/realloc.h</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchtreecpp">trunk/PerformanceTests/MallocBench/MallocBench/tree.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchtreeh">trunk/PerformanceTests/MallocBench/MallocBench/tree.h</a></li>
<li>trunk/PerformanceTests/MallocBench/MallocBench.xcodeproj/</li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchxcodeprojprojectpbxproj">trunk/PerformanceTests/MallocBench/MallocBench.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchrunmallocbenchmarks">trunk/PerformanceTests/MallocBench/run-malloc-benchmarks</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkPerformanceTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/ChangeLog (166666 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/ChangeLog        2014-04-02 21:27:31 UTC (rev 166666)
+++ trunk/PerformanceTests/ChangeLog        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -1,3 +1,95 @@
</span><ins>+2014-04-02  Geoffrey Garen  &lt;ggaren@apple.com&gt;
+
+        Let's benchmark malloc
+        https://bugs.webkit.org/show_bug.cgi?id=131118
+
+        Reviewed by Mark Hahnenberg.
+
+        I want to replace fastMalloc with something faster (fasterMalloc?).
+        I wrote these benchmarks to test / drive development.
+
+        * MallocBench: Added.
+        * MallocBench/MallocBench: Added.
+        * MallocBench/MallocBench.xcodeproj: Added.
+        * MallocBench/MallocBench.xcodeproj/project.pbxproj: Added.
+        * MallocBench/MallocBench/Benchmark.cpp: Added.
+        (allocateHeap):
+        (deallocateHeap):
+        (Benchmark::Benchmark):
+        (Benchmark::printBenchmarks):
+        (Benchmark::runOnce):
+        (Benchmark::run):
+        (Benchmark::printReport):
+        (Benchmark::currentTimeMS):
+        (Benchmark::currentMemoryBytes):
+        * MallocBench/MallocBench/Benchmark.h: Added.
+        (Benchmark::Memory::Memory):
+        (Benchmark::Memory::operator-):
+        (Benchmark::isValid):
+        * MallocBench/MallocBench/CPUCount.cpp: Added.
+        (cpuCount):
+        * MallocBench/MallocBench/CPUCount.h: Added.
+        * MallocBench/MallocBench/CommandLine.cpp: Added.
+        (CommandLine::printUsage):
+        * MallocBench/MallocBench/CommandLine.h: Added.
+        (CommandLine::isValid):
+        (CommandLine::benchmarkName):
+        (CommandLine::isParallel):
+        (CommandLine::heapSize):
+        (CommandLine::measureHeap):
+        * MallocBench/MallocBench/Interpreter.cpp: Added.
+        (Interpreter::Interpreter):
+        (Interpreter::~Interpreter):
+        (Interpreter::run):
+        * MallocBench/MallocBench/Interpreter.h: Added.
+        * MallocBench/MallocBench/balloon.cpp: Added.
+        (benchmark_balloon):
+        * MallocBench/MallocBench/balloon.h: Added.
+        * MallocBench/MallocBench/big.cpp: Added.
+        (benchmark_big):
+        * MallocBench/MallocBench/big.h: Added.
+        * MallocBench/MallocBench/churn.cpp: Added.
+        (HeapDouble::operator new):
+        (HeapDouble::operator delete):
+        (HeapDouble::HeapDouble):
+        (HeapDouble::operator+=):
+        (benchmark_churn):
+        * MallocBench/MallocBench/churn.h: Added.
+        * MallocBench/MallocBench/crash.ops: Added.
+        * MallocBench/MallocBench/facebook.cpp: Added.
+        (benchmark_facebook):
+        * MallocBench/MallocBench/facebook.h: Added.
+        * MallocBench/MallocBench/facebook.ops: Added.
+        * MallocBench/MallocBench/fragment.cpp: Added.
+        (validate):
+        (benchmark_fragment):
+        (benchmark_fragment_iterate):
+        * MallocBench/MallocBench/fragment.h: Added.
+        * MallocBench/MallocBench/list.cpp: Added.
+        (benchmark_list_allocate):
+        (benchmark_list_traverse):
+        * MallocBench/MallocBench/list.h: Added.
+        * MallocBench/MallocBench/main.cpp: Added.
+        (main):
+        * MallocBench/MallocBench/mbmalloc.cpp: Added.
+        * MallocBench/MallocBench/mbmalloc.h: Added.
+        * MallocBench/MallocBench/medium.cpp: Added.
+        (benchmark_medium):
+        * MallocBench/MallocBench/medium.h: Added.
+        * MallocBench/MallocBench/message.cpp: Added.
+        (benchmark_message_one):
+        (benchmark_message_many):
+        * MallocBench/MallocBench/message.h: Added.
+        * MallocBench/MallocBench/realloc.cpp: Added.
+        (benchmark_realloc):
+        * MallocBench/MallocBench/realloc.h: Added.
+        * MallocBench/MallocBench/tree.cpp: Added.
+        (benchmark_tree_allocate):
+        (benchmark_tree_traverse):
+        (benchmark_tree_churn):
+        * MallocBench/MallocBench/tree.h: Added.
+        * MallocBench/run-malloc-benchmarks: Added.
+
</ins><span class="cx"> 2014-03-29  Mark Lam  &lt;mark.lam@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         LongSpider 3d-morph result check is inappropriate.
</span></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchBenchmarkcpp"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/Benchmark.cpp (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/Benchmark.cpp                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/Benchmark.cpp        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,222 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;Benchmark.h&quot;
+#include &quot;CPUCount.h&quot;
+#include &quot;balloon.h&quot;
+#include &quot;big.h&quot;
+#include &quot;churn.h&quot;
+#include &quot;facebook.h&quot;
+#include &quot;fragment.h&quot;
+#include &quot;list.h&quot;
+#include &quot;medium.h&quot;
+#include &quot;message.h&quot;
+#include &quot;tree.h&quot;
+#include &lt;dispatch/dispatch.h&gt;
+#include &lt;iostream&gt;
+#include &lt;mach/mach.h&gt;
+#include &lt;mach/task_info.h&gt;
+#include &lt;map&gt;
+#include &lt;string&gt;
+#include &lt;sys/time.h&gt;
+#include &lt;thread&gt;
+#include &lt;unistd.h&gt;
+
+#include &quot;mbmalloc.h&quot;
+
+using namespace std;
+
+struct BenchmarkPair {
+    const char* const name;
+    const BenchmarkFunction function;
+};
+
+static const BenchmarkPair benchmarkPairs[] = {
+    { &quot;churn&quot;, benchmark_churn },
+    { &quot;list_allocate&quot;, benchmark_list_allocate },
+    { &quot;list_traverse&quot;, benchmark_list_traverse },
+    { &quot;tree_allocate&quot;, benchmark_tree_allocate },
+    { &quot;tree_traverse&quot;, benchmark_tree_traverse },
+    { &quot;tree_churn&quot;, benchmark_tree_churn },
+    { &quot;fragment&quot;, benchmark_fragment },
+    { &quot;fragment_iterate&quot;, benchmark_fragment_iterate },
+    { &quot;message_one&quot;, benchmark_message_one },
+    { &quot;message_many&quot;, benchmark_message_many },
+    { &quot;medium&quot;, benchmark_medium },
+    { &quot;big&quot;, benchmark_big },
+    { &quot;facebook&quot;, benchmark_facebook },
+    { &quot;balloon&quot;, benchmark_balloon },
+};
+
+static const size_t benchmarksPairsCount = sizeof(benchmarkPairs) / sizeof(BenchmarkPair);
+
+static inline bool operator==(const BenchmarkPair&amp; benchmarkPair, const string&amp; string)
+{
+    return string == benchmarkPair.name;
+}
+
+static void*** allocateHeap(size_t heapSize, size_t chunkSize, size_t objectSize)
+{
+    if (!heapSize)
+        return 0;
+
+    size_t chunkCount = heapSize / chunkSize;
+    size_t objectCount = chunkSize / objectSize;
+    void*** chunks = (void***)mbmalloc(chunkCount * sizeof(void**));
+    for (size_t i = 0; i &lt; chunkCount; ++i) {
+        chunks[i] = (void**)mbmalloc(objectCount * sizeof(void*));
+        for (size_t j = 0; j &lt; objectCount; ++j) {
+            chunks[i][j] = (void*)mbmalloc(objectSize);
+            bzero(chunks[i][j], objectSize);
+        }
+    }
+    return chunks;
+}
+
+static void deallocateHeap(void*** chunks, size_t heapSize, size_t chunkSize, size_t objectSize)
+{
+    if (!heapSize)
+        return;
+
+    size_t chunkCount = heapSize / chunkSize;
+    size_t objectCount = chunkSize / objectSize;
+    for (size_t i = 0; i &lt; chunkCount; ++i) {
+        for (size_t j = 0; j &lt; objectCount; ++j)
+            mbfree(chunks[i][j], objectSize);
+        mbfree(chunks[i], objectCount * sizeof(void*));
+    }
+    mbfree(chunks, chunkCount * sizeof(void**));
+}
+
+Benchmark::Benchmark(const string&amp; benchmarkName, bool isParallel, bool measureHeap, size_t heapSize)
+    : m_benchmarkPair()
+    , m_elapsedTime()
+    , m_isParallel(isParallel)
+    , m_heapSize(heapSize)
+    , m_measureHeap(measureHeap)
+{
+    const BenchmarkPair* benchmarkPair = std::find(
+        benchmarkPairs, benchmarkPairs + benchmarksPairsCount, benchmarkName);
+    if (benchmarkPair == benchmarkPairs + benchmarksPairsCount)
+        return;
+    
+    m_benchmarkPair = benchmarkPair;
+}
+    
+void Benchmark::printBenchmarks()
+{
+    cout &lt;&lt; &quot;Benchmarks: &quot; &lt;&lt; endl;
+    for (size_t i = 0; i &lt; benchmarksPairsCount; ++i)
+        cout &lt;&lt; &quot;\t&quot; &lt;&lt; benchmarkPairs[i].name &lt;&lt; endl;
+}
+
+void Benchmark::runOnce()
+{
+    if (!m_isParallel) {
+        m_benchmarkPair-&gt;function(m_isParallel);
+        return;
+    }
+
+    dispatch_group_t group = dispatch_group_create();
+
+    for (size_t i = 0; i &lt; cpuCount(); ++i) {
+        dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
+            m_benchmarkPair-&gt;function(m_isParallel);
+        });
+    }
+
+    dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
+
+    dispatch_release(group);
+}
+
+void Benchmark::run()
+{
+    static const size_t count = 4;
+    static const size_t objectSize = 32;
+    static const size_t chunkSize = 1024 * 1024;
+    
+    void*** heap = allocateHeap(m_heapSize, chunkSize, objectSize);
+
+    runOnce(); // Warmup run.
+
+    for (size_t i = 0; i &lt; count; ++i) {
+        double start = currentTimeMS();
+        runOnce();
+        double end = currentTimeMS();
+        double elapsed = end - start;
+        m_elapsedTime += elapsed;
+    }
+    m_elapsedTime /= count;
+
+    deallocateHeap(heap, m_heapSize, chunkSize, objectSize);
+    
+    if (!m_measureHeap)
+        return;
+
+    // Wait a bit for any async freeing to finish.
+    size_t last;
+    do {
+        last = currentMemoryBytes().resident;
+        std::this_thread::sleep_for(std::chrono::seconds(2));
+    } while (currentMemoryBytes().resident &lt; last);
+
+    m_memory = currentMemoryBytes();
+}
+
+void Benchmark::printReport()
+{
+    size_t kB = 1024;
+
+    cout &lt;&lt; &quot;Time:       \t&quot; &lt;&lt; m_elapsedTime &lt;&lt; &quot;ms&quot; &lt;&lt; endl;
+    if (!m_measureHeap)
+        return;
+
+    cout &lt;&lt; &quot;Memory:     \t&quot; &lt;&lt; m_memory.resident / kB &lt;&lt; &quot;kB&quot; &lt;&lt; endl;
+    cout &lt;&lt; &quot;Peak Memory:\t&quot; &lt;&lt; m_memory.residentMax / kB &lt;&lt; &quot;kB&quot; &lt;&lt; endl;
+}
+
+double Benchmark::currentTimeMS()
+{
+    struct timeval now;
+    gettimeofday(&amp;now, 0);
+    return (now.tv_sec * 1000.0) + now.tv_usec / 1000.0;
+}
+
+Benchmark::Memory Benchmark::currentMemoryBytes()
+{
+    Memory memory;
+
+    task_vm_info_data_t vm_info;
+    mach_msg_type_number_t vm_size = TASK_VM_INFO_COUNT;
+    if (KERN_SUCCESS != task_info(mach_task_self(), TASK_VM_INFO_PURGEABLE, (task_info_t)(&amp;vm_info), &amp;vm_size)) {
+        cout &lt;&lt; &quot;Failed to get mach task info&quot; &lt;&lt; endl;
+        exit(1);
+    }
+
+    memory.resident = vm_info.internal - vm_info.purgeable_volatile_pmap;
+    memory.residentMax = vm_info.resident_size_peak;
+    return memory;
+}
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchBenchmarkh"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/Benchmark.h (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/Benchmark.h                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/Benchmark.h        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,86 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef Benchmark_h
+#define Benchmark_h
+
+#include &lt;map&gt;
+#include &lt;string&gt;
+
+typedef void (*BenchmarkFunction)(bool isParallel);
+struct BenchmarkPair;
+
+class Benchmark {
+public:
+    struct Memory {
+        Memory()
+            : resident()
+            , residentMax()
+        {
+        }
+        
+        Memory(size_t resident, size_t residentMax)
+            : resident(resident)
+            , residentMax(residentMax)
+        {
+        }
+
+        Memory operator-(const Memory&amp; other)
+        {
+            return Memory(resident - other.resident, residentMax - other.residentMax);
+        }
+    
+        size_t resident;
+        size_t residentMax;
+    };
+
+    static double currentTimeMS();
+    static Memory currentMemoryBytes();
+
+    Benchmark(const std::string&amp;, bool isParallel, bool measureHeap, size_t heapSize);
+    
+    bool isValid() { return m_benchmarkPair; }
+    
+    void printBenchmarks();
+    void run();
+    void printReport();
+
+private:
+    typedef std::map&lt;std::string, BenchmarkFunction&gt; MapType;
+    
+    void runOnce();
+
+    MapType m_map;
+
+    const BenchmarkPair* m_benchmarkPair;
+    bool m_isParallel;
+    bool m_measureHeap;
+    size_t m_heapSize;
+
+    Memory m_memory;
+    double m_elapsedTime;
+};
+
+#endif // Benchmark_h
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchCPUCountcpp"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/CPUCount.cpp (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/CPUCount.cpp                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/CPUCount.cpp        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;CPUCount.h&quot;
+#include &lt;stdlib.h&gt;
+#include &lt;sys/param.h&gt;
+#include &lt;sys/sysctl.h&gt;
+#include &lt;sys/types.h&gt;
+
+static size_t count;
+
+size_t cpuCount()
+{
+    if (count)
+        return count;
+
+    size_t length = sizeof(count);
+    int name[] = {
+            CTL_HW,
+            HW_NCPU
+    };
+    int sysctlResult = sysctl(name, sizeof(name) / sizeof(int), &amp;count, &amp;length, 0, 0);
+    if (sysctlResult &lt; 0)
+        abort();
+
+    return count;
+}
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchCPUCounth"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/CPUCount.h (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/CPUCount.h                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/CPUCount.h        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef CPUCount_h
+#define CPUCount_h
+
+#include &lt;stddef.h&gt;
+
+size_t cpuCount();
+
+#endif // CPUCount_h
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchCommandLinecpp"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/CommandLine.cpp (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/CommandLine.cpp                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/CommandLine.cpp        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,79 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;CommandLine.h&quot;
+#include &lt;getopt.h&gt;
+#include &lt;iostream&gt;
+
+struct option CommandLine::longOptions[] =
+{
+    {&quot;benchmark&quot;, required_argument, 0, 'b'},
+    {&quot;parallel&quot;, no_argument, 0, 'p'},
+    {&quot;heap&quot;, required_argument, 0, 'h'},
+    {&quot;measure-heap&quot;, no_argument, 0, 'm'},
+    {0, 0, 0, 0}
+};
+
+CommandLine::CommandLine(int argc, char** argv)
+    : m_argc(argc)
+    , m_argv(argv)
+    , m_isParallel()
+    , m_heapSize()
+    , m_measureHeap()
+{
+    int optionIndex = 0;
+    int ch;
+    while ((ch = getopt_long(argc, argv, &quot;b:p:h:m&quot;, longOptions, &amp;optionIndex)) != -1) {
+        switch (ch)
+        {
+            case 'b':
+                m_benchmarkName = optarg;
+                break;
+
+            case 'p':
+                m_isParallel = true;
+                break;
+
+            case 'h':
+                m_heapSize = atoi(optarg) * 1024 * 1024;
+                break;
+
+            case 'm':
+                m_measureHeap = true;
+                break;
+
+            default:
+                break;
+        }
+    }
+}
+
+void CommandLine::printUsage()
+{
+    std::string fullPath(m_argv[0]);
+    size_t pos = fullPath.find_last_of(&quot;/&quot;) + 1;
+    std::string program = fullPath.substr(pos);
+    std::cout &lt;&lt; &quot;Usage: &quot; &lt;&lt; program &lt;&lt; &quot; --benchmark benchmark_name [ --parallel ] [ --measure-heap ] [ --heap MB ]&quot; &lt;&lt; std::endl;
+}
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchCommandLineh"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/CommandLine.h (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/CommandLine.h                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/CommandLine.h        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &lt;string&gt;
+
+class CommandLine {
+public:
+    CommandLine(int argc, char** argv);
+
+    bool isValid() { return m_benchmarkName.size(); }
+    const std::string&amp; benchmarkName() { return m_benchmarkName; }
+    bool isParallel() { return m_isParallel; }
+    size_t heapSize() { return m_heapSize; }
+    bool measureHeap() { return m_measureHeap; }
+
+    void printUsage();
+
+private:
+    static struct option longOptions[];
+
+    int m_argc;
+    char** m_argv;
+    std::string m_benchmarkName;
+    bool m_isParallel;
+    size_t m_heapSize;
+    bool m_measureHeap;
+};
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchInterpretercpp"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/Interpreter.cpp (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/Interpreter.cpp                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/Interpreter.cpp        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,125 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;CPUCount.h&quot;
+#include &quot;Interpreter.h&quot;
+#include &lt;assert.h&gt;
+#include &lt;cstddef&gt;
+#include &lt;cstdlib&gt;
+#include &lt;errno.h&gt;
+#include &lt;fcntl.h&gt;
+#include &lt;string&gt;
+#include &lt;sys/mman.h&gt;
+#include &lt;sys/stat.h&gt;
+#include &lt;sys/types.h&gt;
+#include &lt;sys/uio.h&gt;
+#include &lt;unistd.h&gt;
+#include &lt;vector&gt;
+
+#include &quot;mbmalloc.h&quot;
+
+Interpreter::Interpreter(const char* fileName)
+{
+    m_fd = open(fileName, O_RDWR, S_IRUSR | S_IWUSR);
+    if (m_fd == -1)
+        fprintf(stderr, &quot;failed to open\n&quot;);
+
+    struct stat buf;
+    fstat(m_fd, &amp;buf);
+
+    m_opCount = buf.st_size / sizeof(Op);
+    assert(m_opCount * sizeof(Op) == buf.st_size);
+
+    size_t maxSlot = 0;
+
+    std::vector&lt;Op&gt; ops(1024);
+    size_t remaining = m_opCount * sizeof(Op);
+    while (remaining) {
+        size_t bytes = std::min(remaining, ops.size() * sizeof(Op));
+        remaining -= bytes;
+        read(m_fd, ops.data(), bytes);
+
+        size_t opCount = bytes / sizeof(Op);
+        for (size_t i = 0; i &lt; opCount; ++i) {
+            Op op = ops[i];
+            if (op.slot &gt; maxSlot)
+                maxSlot = op.slot;
+        }
+    }
+
+    m_objects.resize(maxSlot + 1);
+}
+
+Interpreter::~Interpreter()
+{
+    int result = close(m_fd);
+    if (result == -1)
+        fprintf(stderr, &quot;failed to close\n&quot;);
+}
+
+void Interpreter::run()
+{
+    std::vector&lt;Op&gt; ops(1024);
+    lseek(m_fd, 0, SEEK_SET);
+    size_t remaining = m_opCount * sizeof(Op);
+    while (remaining) {
+        size_t bytes = std::min(remaining, ops.size() * sizeof(Op));
+        remaining -= bytes;
+        read(m_fd, ops.data(), bytes);
+
+        size_t opCount = bytes / sizeof(Op);
+        for (size_t i = 0; i &lt; opCount; ++i) {
+            Op op = ops[i];
+            switch (op.opcode) {
+            case op_a: {
+                m_objects[op.slot] = { mbmalloc(op.size), op.size };
+                assert(m_objects[op.slot].object);
+                bzero(m_objects[op.slot].object, op.size);
+                break;
+            }
+            case op_d: {
+                assert(m_objects[op.slot].object);
+                assert(m_objects[op.slot].size);
+                mbfree(m_objects[op.slot].object, m_objects[op.slot].size);
+                m_objects[op.slot] = { 0, 0 };
+                break;
+            }
+            default: {
+                fprintf(stderr, &quot;bad opcode: %d\n&quot;, op.opcode);
+                abort();
+                break;
+            }
+            }
+        }
+    }
+
+    // A recording might not free all of its allocations.
+    for (size_t i = 0; i &lt; m_objects.size(); ++i) {
+        if (!m_objects[i].object)
+            continue;
+        mbfree(m_objects[i].object, m_objects[i].size);
+        m_objects[i] = { 0, 0 };
+    }
+}
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchInterpreterh"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/Interpreter.h (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/Interpreter.h                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/Interpreter.h        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef Interpreter_h
+#define Interpreter_h
+
+#include &lt;vector&gt;
+
+class Interpreter {
+public:
+    Interpreter(const char* fileName);
+    ~Interpreter();
+
+    void run();
+
+private:
+    enum Opcode { op_a, op_d };
+    struct Op { Opcode opcode; size_t slot; size_t size; };
+    struct Record { void* object; size_t size; };
+
+    int m_fd;
+    size_t m_opCount;
+    std::vector&lt;Record&gt; m_objects;
+};
+
+#endif // Interpreter_h
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchballooncpp"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/balloon.cpp (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/balloon.cpp                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/balloon.cpp        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,74 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;Benchmark.h&quot;
+#include &quot;CPUCount.h&quot;
+#include &quot;balloon.h&quot;
+#include &lt;array&gt;
+#include &lt;chrono&gt;
+#include &lt;memory&gt;
+#include &lt;stddef.h&gt;
+
+#include &quot;mbmalloc.h&quot;
+
+void benchmark_balloon(bool isParallel)
+{
+    const size_t chunkSize = 1 * 1024;
+    const size_t balloonSize = 100 * 1024 * 1024;
+    const size_t steadySize = 10 * 1024 * 1024;
+    
+    std::array&lt;void*, balloonSize / chunkSize&gt; balloon;
+    std::array&lt;void*, balloonSize / chunkSize&gt; steady;
+
+    auto start = std::chrono::steady_clock::now();
+
+    for (size_t i = 0; i &lt; balloon.size(); ++i) {
+        balloon[i] = mbmalloc(chunkSize);
+        bzero(balloon[i], chunkSize);
+    }
+
+    for (size_t i = 0; i &lt; balloon.size(); ++i)
+        mbfree(balloon[i], chunkSize);
+
+    auto stop = std::chrono::steady_clock::now();
+    
+    auto benchmarkTime = stop - start;
+
+    start = std::chrono::steady_clock::now();
+
+    // Converts bytes to time -- for reporting's sake -- by waiting a while until
+    // the heap shrinks back down. This isn't great for pooling with other
+    // benchmarks in a geometric mean of throughput, but it's OK for basic testing.
+    while (Benchmark::currentMemoryBytes().resident &gt; 2 * steadySize
+        &amp;&amp; std::chrono::steady_clock::now() - start &lt; 8 * benchmarkTime) {
+        for (size_t i = 0; i &lt; steady.size(); ++i) {
+            steady[i] = mbmalloc(chunkSize);
+            bzero(steady[i], chunkSize);
+        }
+
+        for (size_t i = 0; i &lt; steady.size(); ++i)
+            mbfree(steady[i], chunkSize);
+    }
+}
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchballoonh"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/balloon.h (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/balloon.h                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/balloon.h        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef balloon_h
+#define balloon_h
+
+void benchmark_balloon(bool isParallel);
+
+#endif // balloon_h
+
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchbigcpp"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/big.cpp (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/big.cpp                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/big.cpp        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,72 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;CPUCount.h&quot;
+#include &quot;big.h&quot;
+#include &lt;algorithm&gt;
+#include &lt;cstddef&gt;
+#include &lt;cstdlib&gt;
+#include &lt;strings.h&gt;
+
+#include &quot;mbmalloc.h&quot;
+
+using namespace std;
+
+struct Object {
+    double* p;
+    size_t size;
+};
+
+void benchmark_big(bool isParallel)
+{
+    size_t times = 1;
+
+    size_t vmSize = 1ul * 1024 * 1024 * 1024;
+    size_t objectSizeMin = 4 * 1024;
+    size_t objectSizeMax = 64 * 1024;
+    if (isParallel)
+        vmSize /= cpuCount();
+
+    size_t objectCount = vmSize / objectSizeMin;
+
+    srandom(0); // For consistency between runs.
+
+    for (size_t i = 0; i &lt; times; ++i) {
+        Object* objects = (Object*)mbmalloc(objectCount * sizeof(Object));
+        bzero(objects, objectCount * sizeof(Object));
+
+        for (size_t i = 0, remaining = vmSize; remaining &gt; objectSizeMin; ++i) {
+            size_t size = min(remaining, max(objectSizeMin, random() % objectSizeMax));
+            objects[i] = { (double*)mbmalloc(size), size };
+            bzero(objects[i].p, size);
+            remaining -= size;
+        }
+
+        for (size_t i = 0; i &lt; objectCount &amp;&amp; objects[i].p; ++i)
+            mbfree(objects[i].p, objects[i].size);
+
+        mbfree(objects, objectCount * sizeof(Object));
+    }
+}
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchbigh"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/big.h (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/big.h                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/big.h        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef big_h
+#define big_h
+
+void benchmark_big(bool isParallel);
+
+#endif // big_h
+
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchchurncpp"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/churn.cpp (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/churn.cpp                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/churn.cpp        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,53 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;CPUCount.h&quot;
+#include &quot;churn.h&quot;
+#include &lt;memory&gt;
+#include &lt;stddef.h&gt;
+
+#include &quot;mbmalloc.h&quot;
+
+struct HeapDouble {
+    void* operator new(size_t size) { return mbmalloc(size); }
+    void operator delete(void* p, size_t size) { mbfree(p, size); }
+
+    HeapDouble(double d) : value(d) { }
+    const HeapDouble&amp; operator+=(const HeapDouble&amp; other) { value += other.value; return *this; }
+    double value;
+};
+
+void benchmark_churn(bool isParallel)
+{
+    size_t times = 10000000;
+    if (isParallel)
+        times /= cpuCount();
+
+    auto total = std::unique_ptr&lt;HeapDouble&gt;(new HeapDouble(0.0));
+    for (size_t i = 0; i &lt; times; ++i) {
+        auto heapDouble = std::unique_ptr&lt;HeapDouble&gt;(new HeapDouble(i));
+        *total += *heapDouble;
+    }
+}
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchchurnh"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/churn.h (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/churn.h                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/churn.h        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef churn_h
+#define churn_h
+
+void benchmark_churn(bool isParallel);
+
+#endif // churn_h
+
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchfacebookcpp"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/facebook.cpp (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/facebook.cpp                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/facebook.cpp        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;CPUCount.h&quot;
+#include &quot;Interpreter.h&quot;
+#include &quot;facebook.h&quot;
+#include &lt;assert.h&gt;
+#include &lt;cstddef&gt;
+#include &lt;cstddef&gt;
+#include &lt;cstdlib&gt;
+#include &lt;errno.h&gt;
+#include &lt;fcntl.h&gt;
+#include &lt;string&gt;
+#include &lt;sys/mman.h&gt;
+#include &lt;sys/stat.h&gt;
+#include &lt;sys/types.h&gt;
+#include &lt;sys/uio.h&gt;
+#include &lt;unistd.h&gt;
+#include &lt;vector&gt;
+
+#include &quot;mbmalloc.h&quot;
+
+void benchmark_facebook(bool isParallel)
+{
+    size_t times = 1;
+
+    Interpreter interpreter(&quot;facebook.ops&quot;);
+    for (size_t i = 0; i &lt; times; ++i)
+        interpreter.run();
+}
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchfacebookh"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/facebook.h (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/facebook.h                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/facebook.h        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef facebook_h
+#define facebook_h
+
+void benchmark_facebook(bool isParallel);
+
+#endif // facebook_h
+
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchfacebookops"></a>
<div class="binary"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/facebook.ops</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/PerformanceTests/MallocBench/MallocBench/facebook.ops
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchfragmentcpp"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/fragment.cpp (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/fragment.cpp                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/fragment.cpp        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,147 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;CPUCount.h&quot;
+#include &quot;fragment.h&quot;
+#include &lt;stdlib.h&gt;
+#include &lt;strings.h&gt;
+
+#include &quot;mbmalloc.h&quot;
+
+namespace {
+
+class Node {
+public:
+    void* operator new(size_t size)
+    {
+        return mbmalloc(size);
+    }
+
+    void operator delete(void* p, size_t size)
+    {
+        mbfree(p, size);
+    }
+
+    Node()
+        : m_next(0)
+        , m_payload()
+    {
+    }
+
+    Node(Node* next)
+        : m_next(next)
+        , m_payload()
+    {
+    }
+    
+    Node* next() { return m_next; }
+    
+    void validate()
+    {
+        for (size_t i = 0; i &lt; sizeof(m_payload); ++i) {
+            if (m_payload[i])
+                abort();
+        }
+    }
+
+private:
+    Node* m_next;
+    char m_payload[32 - sizeof(Node*)];
+};
+
+} // namespace
+
+void validate(Node* head)
+{
+    for (Node* node = head; node; node = node-&gt;next())
+        node-&gt;validate();
+}
+
+void benchmark_fragment(bool isParallel)
+{
+    size_t nodeCount = 128 * 1024;
+    if (isParallel)
+        nodeCount /= cpuCount();
+    size_t replaceCount = nodeCount / 4;
+    size_t times = 25;
+
+    srandom(0); // For consistency between runs.
+
+    for (size_t i = 0; i &lt; times; ++i) {
+        Node** nodes = static_cast&lt;Node**&gt;(mbmalloc(nodeCount * sizeof(Node*)));
+        for (size_t i = 0; i &lt; nodeCount; ++i)
+            nodes[i] = new Node;
+
+        for (size_t i = 0; i &lt; replaceCount; ++i) {
+            size_t node = random() % nodeCount;
+
+            delete nodes[node];
+            nodes[node] = new Node;
+        }
+
+        for (size_t node = 0; node &lt; nodeCount; ++node)
+            delete nodes[node];
+        mbfree(nodes, nodeCount * sizeof(Node*));
+    }
+}
+
+void benchmark_fragment_iterate(bool isParallel)
+{
+    size_t nodeCount = 512 * 1024;
+    size_t times = 32;
+    if (isParallel)
+        nodeCount /= cpuCount();
+    size_t replaceCount = nodeCount / 4;
+
+    srandom(0); // For consistency between runs.
+
+    Node** nodes = static_cast&lt;Node**&gt;(mbmalloc(nodeCount * sizeof(Node*)));
+    for (size_t i = 0; i &lt; nodeCount; ++i)
+        nodes[i] = new Node;
+
+    Node* head = 0;
+    for (size_t i = 0; i &lt; replaceCount; ++i) {
+        size_t node = random() % nodeCount;
+
+        delete nodes[node];
+        nodes[node] = 0;
+        head = new Node(head);
+    }
+    
+    for (size_t i = 0; i &lt; times; ++i)
+        validate(head);
+
+    for (Node* next ; head; head = next) {
+        next = head-&gt;next();
+        delete head;
+    }
+
+    for (size_t node = 0; node &lt; nodeCount; ++node) {
+        if (!nodes[node])
+            continue;
+        delete nodes[node];
+    }
+    mbfree(nodes, nodeCount * sizeof(Node*));
+}
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchfragmenth"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/fragment.h (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/fragment.h                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/fragment.h        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef fragment_h
+#define fragment_h
+
+void benchmark_fragment(bool isParallel);
+void benchmark_fragment_iterate(bool isParallel);
+
+#endif // fragment_h
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchlistcpp"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/list.cpp (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/list.cpp                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/list.cpp        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,159 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;CPUCount.h&quot;
+#include &quot;list.h&quot;
+#include &lt;stdlib.h&gt;
+#include &lt;strings.h&gt;
+
+#include &quot;mbmalloc.h&quot;
+
+namespace {
+
+struct Node {
+    void* operator new(size_t size)
+    {
+        return mbmalloc(size);
+    }
+
+    void operator delete(void* p, size_t size)
+    {
+        mbfree(p, size);
+    }
+
+    Node(Node* next, size_t payloadSize)
+        : m_refCount(1)
+        , m_next(next)
+        , m_payload(static_cast&lt;char*&gt;(mbmalloc(payloadSize)))
+        , m_payloadSize(payloadSize)
+    {
+        if (m_next)
+            m_next-&gt;ref();
+        bzero(m_payload, payloadSize);
+    }
+
+    ~Node()
+    {
+        if (m_next)
+            m_next-&gt;deref();
+        mbfree(m_payload, m_payloadSize);
+    }
+
+    void ref()
+    {
+        ++m_refCount;
+    }
+
+    void deref()
+    {
+        if (m_refCount == 1)
+            delete this;
+        else
+            --m_refCount;
+    }
+
+    Node* takeNext()
+    {
+        Node* tmp = m_next;
+        m_next = 0;
+        return tmp;
+    }
+    
+    bool validate()
+    {
+        if (m_payload[0])
+            return false;
+        return true;
+    }
+
+    unsigned m_refCount;
+    Node* m_next;
+    char* m_payload;
+    size_t m_payloadSize;
+};
+
+} // namespace
+
+void benchmark_list_allocate(bool isParallel)
+{
+    Node* head = 0;
+    size_t times = 96;
+    size_t nodes = 32 * 1024;
+    if (isParallel) {
+        nodes /= cpuCount();
+        times *= 2;
+    }
+    
+    for (size_t time = 0; time &lt; times; ++time) {
+        // Construct a list of nodes.
+        for (size_t node = 0; node &lt; nodes; ++node) {
+            Node* oldHead = head;
+            head = new Node(oldHead, (nodes &amp; (64 - 1)) | 1);
+            if (oldHead)
+                oldHead-&gt;deref();
+        }
+
+        // Tear down the list.
+        while (head) {
+            Node* tmp = head-&gt;takeNext();
+            head-&gt;deref();
+            head = tmp;
+        }
+    }
+}
+
+void benchmark_list_traverse(bool isParallel)
+{
+    Node* head = 0;
+    size_t times = 1 * 1024;
+    size_t nodes = 32 * 1024;
+    if (isParallel) {
+        nodes /= cpuCount();
+        times *= 4;
+    }
+
+    // Construct a list of nodes.
+    for (size_t node = 0; node &lt; nodes; ++node) {
+        Node* oldHead = head;
+        head = new Node(oldHead, (nodes &amp; (64 - 1)) | 1);
+        if (oldHead)
+            oldHead-&gt;deref();
+    }
+
+    // Validate the list.
+    for (size_t time = 0; time &lt; times; ++time) {
+        for (Node* node = head; node; node = node-&gt;m_next) {
+            if (!node-&gt;validate())
+                abort();
+        }
+    }
+
+    // Tear down the list.
+    while (head) {
+        Node* tmp = head-&gt;takeNext();
+        head-&gt;deref();
+        head = tmp;
+    }
+}
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchlisth"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/list.h (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/list.h                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/list.h        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef list_h
+#define list_h
+
+void benchmark_list_allocate(bool isParallel);
+void benchmark_list_traverse(bool isParallel);
+
+#endif // list_h
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchmaincpp"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/main.cpp (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/main.cpp                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/main.cpp        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,61 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;Benchmark.h&quot;
+#include &quot;CommandLine.h&quot;
+#include &lt;iostream&gt;
+#include &lt;map&gt;
+#include &lt;sstream&gt;
+#include &lt;string&gt;
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+    CommandLine commandLine(argc, argv);
+    if (!commandLine.isValid()) {
+        commandLine.printUsage();
+        exit(1);
+    }
+
+    Benchmark benchmark(commandLine.benchmarkName(), commandLine.isParallel(), commandLine.measureHeap(), commandLine.heapSize());
+    if (!benchmark.isValid()) {
+        cout &lt;&lt; &quot;Invalid benchmark: &quot; &lt;&lt; commandLine.benchmarkName() &lt;&lt; endl &lt;&lt; endl;
+        benchmark.printBenchmarks();
+        exit(1);
+    }
+
+    string parallel = commandLine.isParallel() ? string(&quot; [ parallel ]&quot;) : string(&quot; [ not parallel ]&quot;);
+    stringstream heapSize;
+    if (commandLine.heapSize())
+        heapSize &lt;&lt; &quot; [ heap: &quot; &lt;&lt; commandLine.heapSize() / 1024 / 1024 &lt;&lt; &quot;MB ]&quot;;
+    else
+        heapSize &lt;&lt; &quot; [ heap: 0MB ]&quot;;
+    cout &lt;&lt; &quot;Running &quot; &lt;&lt; commandLine.benchmarkName() &lt;&lt; parallel &lt;&lt; heapSize.str() &lt;&lt; &quot;...&quot; &lt;&lt; endl;
+    benchmark.run();
+    benchmark.printReport();
+        
+    return 0;
+}
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchmbmalloccpp"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.cpp (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.cpp                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.cpp        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,47 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &lt;limits&gt;
+#include &lt;stdio.h&gt;
+#include &lt;stdlib.h&gt;
+
+extern &quot;C&quot; {
+
+void* mbmalloc(size_t size)
+{
+    return malloc(size);
+}
+
+void mbfree(void* p, size_t)
+{
+    return free(p);
+}
+
+void* mbrealloc(void* p, size_t, size_t newSize)
+{
+    return realloc(p, newSize);
+}
+
+} // extern &quot;C&quot;
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchmbmalloch"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.h (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.h                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.h        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,51 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef mbmalloc_h
+#define mbmalloc_h
+
+#include &lt;stddef.h&gt;
+
+// This file defines a default implementation of the mbmalloc API, using system
+// malloc. To test with another malloc, supply an override .dylib that exports
+// these symbols.
+
+extern &quot;C&quot; {
+
+void* mbmalloc(size_t);
+void mbfree(void*, size_t);
+void* mbrealloc(void*, size_t, size_t);
+
+}
+
+// Catch accidental benchmark allocation through malloc and free. All benchmark
+// code should use mbmalloc / mbfree, to call the instrumented malloc we're
+// benchmarking against.
+
+#define malloc error
+#define free error
+#define realloc error
+
+#endif // mbmalloc_h
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchmediumcpp"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/medium.cpp (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/medium.cpp                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/medium.cpp        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,72 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;CPUCount.h&quot;
+#include &quot;medium.h&quot;
+#include &lt;algorithm&gt;
+#include &lt;cstddef&gt;
+#include &lt;cstdlib&gt;
+#include &lt;strings.h&gt;
+
+#include &quot;mbmalloc.h&quot;
+
+using namespace std;
+
+struct Object {
+    double* p;
+    size_t size;
+};
+
+void benchmark_medium(bool isParallel)
+{
+    size_t times = 1;
+
+    size_t vmSize = 1ul * 1024 * 1024 * 1024;
+    size_t objectSizeMin = 2 * 1024;
+    size_t objectSizeMax = 8 * 1024;
+    if (isParallel)
+        vmSize /= cpuCount();
+
+    size_t objectCount = vmSize / objectSizeMin;
+
+    srandom(0); // For consistency between runs.
+
+    for (size_t i = 0; i &lt; times; ++i) {
+        Object* objects = (Object*)mbmalloc(objectCount * sizeof(Object));
+        bzero(objects, objectCount * sizeof(Object));
+
+        for (size_t i = 0, remaining = vmSize; remaining &gt; objectSizeMin; ++i) {
+            size_t size = min(remaining, max(objectSizeMin, random() % objectSizeMax));
+            objects[i] = { (double*)mbmalloc(size), size };
+            bzero(objects[i].p, size);
+            remaining -= size;
+        }
+
+        for (size_t i = 0; i &lt; objectCount &amp;&amp; objects[i].p; ++i)
+            mbfree(objects[i].p, objects[i].size);
+
+        mbfree(objects, objectCount * sizeof(Object));
+    }
+}
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchmediumh"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/medium.h (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/medium.h                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/medium.h        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef medium_h
+#define medium_h
+
+void benchmark_medium(bool isParallel);
+
+#endif // medium_h
+
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchmessagecpp"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/message.cpp (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/message.cpp                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/message.cpp        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,176 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;CPUCount.h&quot;
+#include &quot;message.h&quot;
+#include &lt;dispatch/dispatch.h&gt;
+#include &lt;stdlib.h&gt;
+#include &lt;strings.h&gt;
+
+#include &quot;mbmalloc.h&quot;
+
+namespace {
+
+size_t hash(size_t hash, unsigned short a, unsigned short b)
+{
+    hash += a ^ b;
+    return hash;
+}
+
+class Node {
+    static const size_t payloadCount = 128;
+public:
+    void* operator new(size_t size)
+    {
+        return mbmalloc(size);
+    }
+
+    void operator delete(void* p, size_t size)
+    {
+        mbfree(p, size);
+    }
+
+    Node()
+        : m_payload()
+    {
+    }
+
+    size_t hash(size_t hash)
+    {
+        for (size_t i = 0; i &lt; payloadCount; i += 2)
+            hash = ::hash(hash, m_payload[i], m_payload[i + 1]);
+        return hash;
+    }
+
+private:
+    unsigned short m_payload[payloadCount];
+};
+
+class Message {
+    static const size_t nodeCount = 1 * 1024;
+
+public:
+    void* operator new(size_t size)
+    {
+        return mbmalloc(size);
+    }
+
+    void operator delete(void* p, size_t size)
+    {
+        mbfree(p, size);
+    }
+
+    Message()
+        : m_buffer(static_cast&lt;Node**&gt;(mbmalloc(nodeCount * sizeof(Node**))))
+    {
+        for (size_t i = 0; i &lt; nodeCount; ++i)
+            m_buffer[i] = new Node;
+    }
+    
+    ~Message()
+    {
+        for (size_t i = 0; i &lt; nodeCount; ++i)
+            delete m_buffer[i];
+        mbfree(m_buffer, nodeCount * sizeof(Node**));
+    }
+
+    size_t hash()
+    {
+        size_t hash = 0;
+        for (size_t i = 0; i &lt; nodeCount; ++i)
+            hash = m_buffer[i]-&gt;hash(hash);
+        return hash;
+    }
+
+private:
+    Node** m_buffer;
+};
+
+} // namespace
+
+void benchmark_message_one(bool isParallel)
+{
+    if (isParallel)
+        abort();
+
+    const size_t times = 2048;
+    const size_t quantum = 16;
+
+    dispatch_queue_t queue = dispatch_queue_create(&quot;message&quot;, 0);
+
+    for (size_t i = 0; i &lt; times; i += quantum) {
+        for (size_t j = 0; j &lt; quantum; ++j) {
+            Message* message = new Message;
+            dispatch_async(queue, ^{
+                size_t hash = message-&gt;hash();
+                if (hash)
+                    abort();
+                delete message;
+            });
+        }
+        dispatch_sync(queue, ^{ });
+    }
+
+    dispatch_sync(queue, ^{ });
+
+    dispatch_release(queue);
+}
+
+void benchmark_message_many(bool isParallel)
+{
+    if (isParallel)
+        abort();
+
+    const size_t times = 768;
+    const size_t quantum = 16;
+
+    const size_t queueCount = cpuCount() - 1;
+    dispatch_queue_t queues[queueCount];
+    for (size_t i = 0; i &lt; queueCount; ++i)
+        queues[i] = dispatch_queue_create(&quot;message&quot;, 0);
+
+    for (size_t i = 0; i &lt; times; i += quantum) {
+        for (size_t j = 0; j &lt; quantum; ++j) {
+            for (size_t k = 0; k &lt; queueCount; ++k) {
+                Message* message = new Message;
+                dispatch_async(queues[k], ^{
+                    size_t hash = message-&gt;hash();
+                    if (hash)
+                        abort();
+                    delete message;
+                });
+            }
+        }
+
+        for (size_t i = 0; i &lt; queueCount; ++i)
+            dispatch_sync(queues[i], ^{ });
+    }
+
+    for (size_t i = 0; i &lt; queueCount; ++i)
+        dispatch_sync(queues[i], ^{ });
+
+    for (size_t i = 0; i &lt; queueCount; ++i)
+        dispatch_release(queues[i]);
+}
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchmessageh"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/message.h (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/message.h                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/message.h        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef message_h
+#define message_h
+
+void benchmark_message_one(bool isParallel);
+void benchmark_message_many(bool isParallel);
+
+#endif // message_h
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchrealloccpp"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/realloc.cpp (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/realloc.cpp                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/realloc.cpp        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,34 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;realloc.h&quot;
+#include &lt;memory&gt;
+#include &lt;stddef.h&gt;
+
+#include &quot;mbmalloc.h&quot;
+
+void benchmark_realloc(bool isParallel)
+{
+}
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchrealloch"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/realloc.h (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/realloc.h                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/realloc.h        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef realloc_h
+#define realloc_h
+
+void benchmark_realloc(bool isParallel);
+
+#endif // realloc_h
+
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchtreecpp"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/tree.cpp (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/tree.cpp                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/tree.cpp        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,221 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;tree.h&quot;
+#include &lt;limits&gt;
+#include &lt;stdlib.h&gt;
+#include &lt;strings.h&gt;
+
+#include &quot;mbmalloc.h&quot;
+
+namespace {
+
+struct Node {
+    void* operator new(size_t size)
+    {
+        return mbmalloc(size);
+    }
+
+    void operator delete(void* p, size_t size)
+    {
+        mbfree(p, size);
+    }
+
+    Node(Node* left, Node* right, size_t payloadSize, size_t id)
+        : m_refCount(1)
+        , m_left(left)
+        , m_right(right)
+        , m_payload(static_cast&lt;char*&gt;(mbmalloc(payloadSize)))
+        , m_payloadSize(payloadSize)
+        , m_id(id)
+    {
+        if (m_left)
+            m_left-&gt;ref();
+        if (m_right)
+            m_right-&gt;ref();
+        bzero(m_payload, payloadSize);
+    }
+
+    ~Node()
+    {
+        if (m_left)
+            m_left-&gt;deref();
+        if (m_right)
+            m_right-&gt;deref();
+        mbfree(m_payload, m_payloadSize);
+    }
+
+    void ref()
+    {
+        ++m_refCount;
+    }
+
+    void deref()
+    {
+        if (m_refCount == 1)
+            delete this;
+        else
+            --m_refCount;
+    }
+    
+    size_t id() { return m_id; }
+    Node* left() { return m_left; }
+    Node* right() { return m_right; }
+
+    void setLeft(Node* left)
+    {
+        left-&gt;ref();
+        if (m_left)
+            m_left-&gt;deref();
+        
+        m_left = left;
+    }
+
+    void setRight(Node* right)
+    {
+        right-&gt;ref();
+        if (m_right)
+            m_right-&gt;deref();
+        
+        m_right = right;
+    }
+
+    unsigned m_refCount;
+    Node* m_left;
+    Node* m_right;
+    char* m_payload;
+    size_t m_payloadSize;
+    size_t m_id;
+};
+
+void verify(Node* node, Node* left, Node* right)
+{
+    if (left &amp;&amp; left-&gt;id() &gt;= node-&gt;id())
+        abort();
+
+    if (right &amp;&amp; right-&gt;id() &lt;= node-&gt;id())
+        abort();
+}
+
+Node* createTree(size_t depth, size_t&amp; counter)
+{
+    if (!depth)
+        return 0;
+
+    Node* left = createTree(depth - 1, counter);
+    size_t id = counter++;
+    Node* right = createTree(depth - 1, counter);
+
+    Node* result = new Node(left, right, ((depth * 8) &amp; (64 - 1)) | 1, id);
+
+    verify(result, left, right);
+
+    if (left)
+        left-&gt;deref();
+    if (right)
+        right-&gt;deref();
+    return result;
+}
+
+Node* createTree(size_t depth)
+{
+    size_t counter = 0;
+    return createTree(depth, counter);
+}
+
+void churnTree(Node* node, size_t stride, size_t&amp; counter)
+{
+    if (!node)
+        return;
+    
+    churnTree(node-&gt;left(), stride, counter);
+
+    if (node-&gt;left() &amp;&amp; !(counter % stride)) {
+        Node* left = new Node(node-&gt;left()-&gt;left(), node-&gt;left()-&gt;right(), (counter &amp; (64 - 1)) | 1, node-&gt;left()-&gt;id());
+        Node* right = new Node(node-&gt;right()-&gt;left(), node-&gt;right()-&gt;right(), (counter &amp; (64 - 1)) | 1, node-&gt;right()-&gt;id());
+        node-&gt;setLeft(left);
+        node-&gt;setRight(right);
+        left-&gt;deref();
+        right-&gt;deref();
+    }
+    ++counter;
+
+    churnTree(node-&gt;right(), stride, counter);
+
+    verify(node, node-&gt;left(), node-&gt;right());
+}
+
+void churnTree(Node* tree, size_t stride)
+{
+    size_t counter;
+    churnTree(tree, stride, counter);
+}
+
+} // namespace
+
+void benchmark_tree_allocate(bool isParallel)
+{
+    size_t times = 24;
+    size_t depth = 16;
+    if (isParallel) {
+        times *= 4;
+        depth = 13;
+    }
+
+    for (size_t time = 0; time &lt; times; ++time) {
+        Node* tree = createTree(depth);
+        tree-&gt;deref();
+    }
+}
+
+void benchmark_tree_traverse(bool isParallel)
+{
+    size_t times = 256;
+    size_t depth = 15;
+    if (isParallel) {
+        times = 512;
+        depth = 13;
+    }
+
+    Node* tree = createTree(depth);
+    for (size_t time = 0; time &lt; times; ++time)
+        churnTree(tree, std::numeric_limits&lt;size_t&gt;::max()); // Reuse this to iterate and validate.
+    tree-&gt;deref();
+}
+
+void benchmark_tree_churn(bool isParallel)
+{
+    size_t times = 160;
+    size_t depth = 15;
+    if (isParallel) {
+        times *= 4;
+        depth = 12;
+    }
+
+    Node* tree = createTree(depth);
+    for (size_t time = 0; time &lt; times; ++time)
+        churnTree(tree, 8);
+    tree-&gt;deref();
+}
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchtreeh"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/tree.h (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/tree.h                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/tree.h        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef tree_h
+#define tree_h
+
+void benchmark_tree_allocate(bool isParallel);
+void benchmark_tree_traverse(bool isParallel);
+void benchmark_tree_churn(bool isParallel);
+
+#endif // tree_h
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchxcodeprojprojectpbxproj"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench.xcodeproj/project.pbxproj (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench.xcodeproj/project.pbxproj                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench.xcodeproj/project.pbxproj        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,449 @@
</span><ins>+// !$*UTF8*$!
+{
+        archiveVersion = 1;
+        classes = {
+        };
+        objectVersion = 46;
+        objects = {
+
+/* Begin PBXBuildFile section */
+                14105E7F18DF7D73003A106E /* balloon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14105E7D18DF7D73003A106E /* balloon.cpp */; };
+                14105E8218E13EEC003A106E /* realloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14105E8018E13EEC003A106E /* realloc.cpp */; };
+                1444AE93177E79BB00F8030A /* fragment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1444AE91177E79BB00F8030A /* fragment.cpp */; };
+                1444AE96177E8DF200F8030A /* message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1444AE94177E8DF200F8030A /* message.cpp */; };
+                14452CB0177D24460097E057 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14452CAF177D24460097E057 /* main.cpp */; };
+                14452CEF177D47110097E057 /* churn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14452CED177D47110097E057 /* churn.cpp */; };
+                1451FAED18B14B7100DB6D47 /* medium.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1451FAEB18B14B7100DB6D47 /* medium.cpp */; };
+                14976EC8177E3649006B819A /* list.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14976EC6177E3649006B819A /* list.cpp */; };
+                14976ECC177E3C87006B819A /* CommandLine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14976ECB177E3C87006B819A /* CommandLine.cpp */; };
+                14976ECE177E3D67006B819A /* Benchmark.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14976ECD177E3D67006B819A /* Benchmark.cpp */; };
+                14976ED1177E4AF7006B819A /* tree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14976ECF177E4AF7006B819A /* tree.cpp */; };
+                14C5008D184016CF007A531D /* facebook.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14C5008B184016CF007A531D /* facebook.cpp */; };
+                14C5009018401841007A531D /* facebook.ops in CopyFiles */ = {isa = PBXBuildFile; fileRef = 14C5008E18401726007A531D /* facebook.ops */; };
+                14C5009318403DA0007A531D /* Interpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14C5009118403DA0007A531D /* Interpreter.cpp */; };
+                14CC393C18EA812B004AFE34 /* libmbmalloc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 14CC393818EA811F004AFE34 /* libmbmalloc.dylib */; settings = {ATTRIBUTES = (Weak, ); }; };
+                14CC393F18EA8184004AFE34 /* mbmalloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14CC391C18EA6759004AFE34 /* mbmalloc.cpp */; };
+                14CE4A6017BD355800288DAA /* big.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14CE4A5E17BD355800288DAA /* big.cpp */; };
+                14E11932177ECC8B003A8D15 /* CPUCount.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14E11930177ECC8B003A8D15 /* CPUCount.cpp */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+                14CC393D18EA813F004AFE34 /* PBXContainerItemProxy */ = {
+                        isa = PBXContainerItemProxy;
+                        containerPortal = 14452CA1177D24460097E057 /* Project object */;
+                        proxyType = 1;
+                        remoteGlobalIDString = 14CC393718EA811F004AFE34;
+                        remoteInfo = mbmalloc;
+                };
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+                14452CA7177D24460097E057 /* CopyFiles */ = {
+                        isa = PBXCopyFilesBuildPhase;
+                        buildActionMask = 12;
+                        dstPath = &quot;&quot;;
+                        dstSubfolderSpec = 7;
+                        files = (
+                                14C5009018401841007A531D /* facebook.ops in CopyFiles */,
+                        );
+                        runOnlyForDeploymentPostprocessing = 0;
+                };
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+                14105E7D18DF7D73003A106E /* balloon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = balloon.cpp; path = MallocBench/balloon.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14105E7E18DF7D73003A106E /* balloon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = balloon.h; path = MallocBench/balloon.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14105E8018E13EEC003A106E /* realloc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = realloc.cpp; path = MallocBench/realloc.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14105E8118E13EEC003A106E /* realloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = realloc.h; path = MallocBench/realloc.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                1444AE91177E79BB00F8030A /* fragment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = fragment.cpp; path = MallocBench/fragment.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                1444AE92177E79BB00F8030A /* fragment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = fragment.h; path = MallocBench/fragment.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                1444AE94177E8DF200F8030A /* message.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = message.cpp; path = MallocBench/message.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                1444AE95177E8DF200F8030A /* message.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = message.h; path = MallocBench/message.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14452CA9177D24460097E057 /* MallocBench */ = {isa = PBXFileReference; explicitFileType = &quot;compiled.mach-o.executable&quot;; includeInIndex = 0; path = MallocBench; sourceTree = BUILT_PRODUCTS_DIR; };
+                14452CAF177D24460097E057 /* main.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14452CED177D47110097E057 /* churn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = churn.cpp; path = MallocBench/churn.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14452CEE177D47110097E057 /* churn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = churn.h; path = MallocBench/churn.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                1451FAEB18B14B7100DB6D47 /* medium.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = medium.cpp; path = MallocBench/medium.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                1451FAEC18B14B7100DB6D47 /* medium.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = medium.h; path = MallocBench/medium.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14976EC6177E3649006B819A /* list.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = list.cpp; path = MallocBench/list.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14976EC7177E3649006B819A /* list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = list.h; path = MallocBench/list.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14976EC9177E3B4A006B819A /* Benchmark.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Benchmark.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14976ECA177E3C05006B819A /* CommandLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommandLine.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14976ECB177E3C87006B819A /* CommandLine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommandLine.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14976ECD177E3D67006B819A /* Benchmark.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Benchmark.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14976ECF177E4AF7006B819A /* tree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tree.cpp; path = MallocBench/tree.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14976ED0177E4AF7006B819A /* tree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tree.h; path = MallocBench/tree.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14C5008B184016CF007A531D /* facebook.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = facebook.cpp; path = MallocBench/facebook.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14C5008C184016CF007A531D /* facebook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = facebook.h; path = MallocBench/facebook.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14C5008E18401726007A531D /* facebook.ops */ = {isa = PBXFileReference; lastKnownFileType = file; name = facebook.ops; path = MallocBench/facebook.ops; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14C5009118403DA0007A531D /* Interpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Interpreter.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14C5009218403DA0007A531D /* Interpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Interpreter.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14CC391C18EA6759004AFE34 /* mbmalloc.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mbmalloc.cpp; path = MallocBench/mbmalloc.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14CC393818EA811F004AFE34 /* libmbmalloc.dylib */ = {isa = PBXFileReference; explicitFileType = &quot;compiled.mach-o.dylib&quot;; includeInIndex = 0; path = libmbmalloc.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
+                14CE4A5E17BD355800288DAA /* big.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = big.cpp; path = MallocBench/big.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14CE4A5F17BD355800288DAA /* big.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = big.h; path = MallocBench/big.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14E11930177ECC8B003A8D15 /* CPUCount.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPUCount.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14E11931177ECC8B003A8D15 /* CPUCount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPUCount.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14E11934177F5219003A8D15 /* mbmalloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mbmalloc.h; path = MallocBench/mbmalloc.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+                14452CA6177D24460097E057 /* Frameworks */ = {
+                        isa = PBXFrameworksBuildPhase;
+                        buildActionMask = 2147483647;
+                        files = (
+                                14CC393C18EA812B004AFE34 /* libmbmalloc.dylib in Frameworks */,
+                        );
+                        runOnlyForDeploymentPostprocessing = 0;
+                };
+                14CC393518EA811F004AFE34 /* Frameworks */ = {
+                        isa = PBXFrameworksBuildPhase;
+                        buildActionMask = 2147483647;
+                        files = (
+                        );
+                        runOnlyForDeploymentPostprocessing = 0;
+                };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+                14452CA0177D24460097E057 = {
+                        isa = PBXGroup;
+                        children = (
+                                14E11933177F51AC003A8D15 /* Benchmarks */,
+                                14452CAE177D24460097E057 /* MallocBench */,
+                                14CC391B18EA6722004AFE34 /* mbmalloc */,
+                                14452CAA177D24460097E057 /* Products */,
+                        );
+                        sourceTree = &quot;&lt;group&gt;&quot;;
+                };
+                14452CAA177D24460097E057 /* Products */ = {
+                        isa = PBXGroup;
+                        children = (
+                                14452CA9177D24460097E057 /* MallocBench */,
+                                14CC393818EA811F004AFE34 /* libmbmalloc.dylib */,
+                        );
+                        name = Products;
+                        sourceTree = &quot;&lt;group&gt;&quot;;
+                };
+                14452CAE177D24460097E057 /* MallocBench */ = {
+                        isa = PBXGroup;
+                        children = (
+                                14976ECD177E3D67006B819A /* Benchmark.cpp */,
+                                14976EC9177E3B4A006B819A /* Benchmark.h */,
+                                14976ECB177E3C87006B819A /* CommandLine.cpp */,
+                                14976ECA177E3C05006B819A /* CommandLine.h */,
+                                14E11930177ECC8B003A8D15 /* CPUCount.cpp */,
+                                14E11931177ECC8B003A8D15 /* CPUCount.h */,
+                                14C5009118403DA0007A531D /* Interpreter.cpp */,
+                                14C5009218403DA0007A531D /* Interpreter.h */,
+                                14452CAF177D24460097E057 /* main.cpp */,
+                        );
+                        path = MallocBench;
+                        sourceTree = &quot;&lt;group&gt;&quot;;
+                };
+                14CC391B18EA6722004AFE34 /* mbmalloc */ = {
+                        isa = PBXGroup;
+                        children = (
+                                14CC391C18EA6759004AFE34 /* mbmalloc.cpp */,
+                                14E11934177F5219003A8D15 /* mbmalloc.h */,
+                        );
+                        name = mbmalloc;
+                        sourceTree = &quot;&lt;group&gt;&quot;;
+                };
+                14E11933177F51AC003A8D15 /* Benchmarks */ = {
+                        isa = PBXGroup;
+                        children = (
+                                14105E7D18DF7D73003A106E /* balloon.cpp */,
+                                14105E7E18DF7D73003A106E /* balloon.h */,
+                                14CE4A5E17BD355800288DAA /* big.cpp */,
+                                14CE4A5F17BD355800288DAA /* big.h */,
+                                14452CED177D47110097E057 /* churn.cpp */,
+                                14452CEE177D47110097E057 /* churn.h */,
+                                14C5008B184016CF007A531D /* facebook.cpp */,
+                                14C5008C184016CF007A531D /* facebook.h */,
+                                14C5008E18401726007A531D /* facebook.ops */,
+                                1444AE91177E79BB00F8030A /* fragment.cpp */,
+                                1444AE92177E79BB00F8030A /* fragment.h */,
+                                14976EC6177E3649006B819A /* list.cpp */,
+                                14976EC7177E3649006B819A /* list.h */,
+                                1451FAEB18B14B7100DB6D47 /* medium.cpp */,
+                                1451FAEC18B14B7100DB6D47 /* medium.h */,
+                                1444AE94177E8DF200F8030A /* message.cpp */,
+                                1444AE95177E8DF200F8030A /* message.h */,
+                                14105E8018E13EEC003A106E /* realloc.cpp */,
+                                14105E8118E13EEC003A106E /* realloc.h */,
+                                14976ECF177E4AF7006B819A /* tree.cpp */,
+                                14976ED0177E4AF7006B819A /* tree.h */,
+                        );
+                        name = Benchmarks;
+                        sourceTree = &quot;&lt;group&gt;&quot;;
+                };
+/* End PBXGroup section */
+
+/* Begin PBXHeadersBuildPhase section */
+                14CC393618EA811F004AFE34 /* Headers */ = {
+                        isa = PBXHeadersBuildPhase;
+                        buildActionMask = 2147483647;
+                        files = (
+                        );
+                        runOnlyForDeploymentPostprocessing = 0;
+                };
+/* End PBXHeadersBuildPhase section */
+
+/* Begin PBXNativeTarget section */
+                14452CA8177D24460097E057 /* MallocBench */ = {
+                        isa = PBXNativeTarget;
+                        buildConfigurationList = 14452CB7177D24460097E057 /* Build configuration list for PBXNativeTarget &quot;MallocBench&quot; */;
+                        buildPhases = (
+                                14452CA5177D24460097E057 /* Sources */,
+                                14452CA6177D24460097E057 /* Frameworks */,
+                                14452CA7177D24460097E057 /* CopyFiles */,
+                        );
+                        buildRules = (
+                        );
+                        dependencies = (
+                                14CC393E18EA813F004AFE34 /* PBXTargetDependency */,
+                        );
+                        name = MallocBench;
+                        productName = MallocBench;
+                        productReference = 14452CA9177D24460097E057 /* MallocBench */;
+                        productType = &quot;com.apple.product-type.tool&quot;;
+                };
+                14CC393718EA811F004AFE34 /* mbmalloc */ = {
+                        isa = PBXNativeTarget;
+                        buildConfigurationList = 14CC393918EA811F004AFE34 /* Build configuration list for PBXNativeTarget &quot;mbmalloc&quot; */;
+                        buildPhases = (
+                                14CC393418EA811F004AFE34 /* Sources */,
+                                14CC393518EA811F004AFE34 /* Frameworks */,
+                                14CC393618EA811F004AFE34 /* Headers */,
+                        );
+                        buildRules = (
+                        );
+                        dependencies = (
+                        );
+                        name = mbmalloc;
+                        productName = mbmalloc;
+                        productReference = 14CC393818EA811F004AFE34 /* libmbmalloc.dylib */;
+                        productType = &quot;com.apple.product-type.library.dynamic&quot;;
+                };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+                14452CA1177D24460097E057 /* Project object */ = {
+                        isa = PBXProject;
+                        attributes = {
+                                LastUpgradeCheck = 0600;
+                                ORGANIZATIONNAME = &quot;Geoffrey Garen&quot;;
+                        };
+                        buildConfigurationList = 14452CA4177D24460097E057 /* Build configuration list for PBXProject &quot;MallocBench&quot; */;
+                        compatibilityVersion = &quot;Xcode 3.2&quot;;
+                        developmentRegion = English;
+                        hasScannedForEncodings = 0;
+                        knownRegions = (
+                                en,
+                        );
+                        mainGroup = 14452CA0177D24460097E057;
+                        productRefGroup = 14452CAA177D24460097E057 /* Products */;
+                        projectDirPath = &quot;&quot;;
+                        projectRoot = &quot;&quot;;
+                        targets = (
+                                14452CA8177D24460097E057 /* MallocBench */,
+                                14CC393718EA811F004AFE34 /* mbmalloc */,
+                        );
+                };
+/* End PBXProject section */
+
+/* Begin PBXSourcesBuildPhase section */
+                14452CA5177D24460097E057 /* Sources */ = {
+                        isa = PBXSourcesBuildPhase;
+                        buildActionMask = 2147483647;
+                        files = (
+                                14CE4A6017BD355800288DAA /* big.cpp in Sources */,
+                                14976ED1177E4AF7006B819A /* tree.cpp in Sources */,
+                                1444AE96177E8DF200F8030A /* message.cpp in Sources */,
+                                14452CEF177D47110097E057 /* churn.cpp in Sources */,
+                                14452CB0177D24460097E057 /* main.cpp in Sources */,
+                                14C5008D184016CF007A531D /* facebook.cpp in Sources */,
+                                14976EC8177E3649006B819A /* list.cpp in Sources */,
+                                14976ECC177E3C87006B819A /* CommandLine.cpp in Sources */,
+                                1451FAED18B14B7100DB6D47 /* medium.cpp in Sources */,
+                                14C5009318403DA0007A531D /* Interpreter.cpp in Sources */,
+                                14E11932177ECC8B003A8D15 /* CPUCount.cpp in Sources */,
+                                1444AE93177E79BB00F8030A /* fragment.cpp in Sources */,
+                                14105E8218E13EEC003A106E /* realloc.cpp in Sources */,
+                                14105E7F18DF7D73003A106E /* balloon.cpp in Sources */,
+                                14976ECE177E3D67006B819A /* Benchmark.cpp in Sources */,
+                        );
+                        runOnlyForDeploymentPostprocessing = 0;
+                };
+                14CC393418EA811F004AFE34 /* Sources */ = {
+                        isa = PBXSourcesBuildPhase;
+                        buildActionMask = 2147483647;
+                        files = (
+                                14CC393F18EA8184004AFE34 /* mbmalloc.cpp in Sources */,
+                        );
+                        runOnlyForDeploymentPostprocessing = 0;
+                };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+                14CC393E18EA813F004AFE34 /* PBXTargetDependency */ = {
+                        isa = PBXTargetDependency;
+                        target = 14CC393718EA811F004AFE34 /* mbmalloc */;
+                        targetProxy = 14CC393D18EA813F004AFE34 /* PBXContainerItemProxy */;
+                };
+/* End PBXTargetDependency section */
+
+/* Begin XCBuildConfiguration section */
+                14452CB5177D24460097E057 /* Debug */ = {
+                        isa = XCBuildConfiguration;
+                        buildSettings = {
+                                ALWAYS_SEARCH_USER_PATHS = NO;
+                                CLANG_CXX_LANGUAGE_STANDARD = &quot;gnu++0x&quot;;
+                                CLANG_CXX_LIBRARY = &quot;libc++&quot;;
+                                CLANG_ENABLE_MODULES = YES;
+                                CLANG_WARN_BOOL_CONVERSION = YES;
+                                CLANG_WARN_CONSTANT_CONVERSION = YES;
+                                CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+                                CLANG_WARN_EMPTY_BODY = YES;
+                                CLANG_WARN_ENUM_CONVERSION = YES;
+                                CLANG_WARN_INT_CONVERSION = YES;
+                                CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+                                CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+                                COPY_PHASE_STRIP = NO;
+                                GCC_C_LANGUAGE_STANDARD = gnu99;
+                                GCC_DYNAMIC_NO_PIC = NO;
+                                GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+                                GCC_OPTIMIZATION_LEVEL = 0;
+                                GCC_PREPROCESSOR_DEFINITIONS = (
+                                        &quot;DEBUG=1&quot;,
+                                        &quot;$(inherited)&quot;,
+                                );
+                                GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+                                GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+                                GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+                                GCC_WARN_UNDECLARED_SELECTOR = YES;
+                                GCC_WARN_UNINITIALIZED_AUTOS = YES;
+                                GCC_WARN_UNUSED_FUNCTION = YES;
+                                GCC_WARN_UNUSED_VARIABLE = YES;
+                                MACOSX_DEPLOYMENT_TARGET = 10.9;
+                                ONLY_ACTIVE_ARCH = YES;
+                                SDKROOT = macosx;
+                        };
+                        name = Debug;
+                };
+                14452CB6177D24460097E057 /* Release */ = {
+                        isa = XCBuildConfiguration;
+                        buildSettings = {
+                                ALWAYS_SEARCH_USER_PATHS = NO;
+                                CLANG_CXX_LANGUAGE_STANDARD = &quot;gnu++0x&quot;;
+                                CLANG_CXX_LIBRARY = &quot;libc++&quot;;
+                                CLANG_ENABLE_MODULES = YES;
+                                CLANG_WARN_BOOL_CONVERSION = YES;
+                                CLANG_WARN_CONSTANT_CONVERSION = YES;
+                                CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+                                CLANG_WARN_EMPTY_BODY = YES;
+                                CLANG_WARN_ENUM_CONVERSION = YES;
+                                CLANG_WARN_INT_CONVERSION = YES;
+                                CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+                                CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+                                COPY_PHASE_STRIP = YES;
+                                DEBUG_INFORMATION_FORMAT = &quot;dwarf-with-dsym&quot;;
+                                ENABLE_NS_ASSERTIONS = NO;
+                                GCC_C_LANGUAGE_STANDARD = gnu99;
+                                GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+                                GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+                                GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+                                GCC_WARN_UNDECLARED_SELECTOR = YES;
+                                GCC_WARN_UNINITIALIZED_AUTOS = YES;
+                                GCC_WARN_UNUSED_FUNCTION = YES;
+                                GCC_WARN_UNUSED_VARIABLE = YES;
+                                MACOSX_DEPLOYMENT_TARGET = 10.9;
+                                SDKROOT = macosx;
+                        };
+                        name = Release;
+                };
+                14452CB8177D24460097E057 /* Debug */ = {
+                        isa = XCBuildConfiguration;
+                        buildSettings = {
+                                GCC_PRECOMPILE_PREFIX_HEADER = NO;
+                                PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO;
+                                PRODUCT_NAME = &quot;$(TARGET_NAME)&quot;;
+                        };
+                        name = Debug;
+                };
+                14452CB9177D24460097E057 /* Release */ = {
+                        isa = XCBuildConfiguration;
+                        buildSettings = {
+                                GCC_PRECOMPILE_PREFIX_HEADER = NO;
+                                ONLY_ACTIVE_ARCH = YES;
+                                &quot;OTHER_CFLAGS[arch=*]&quot; = &quot;&quot;;
+                                &quot;OTHER_CPLUSPLUSFLAGS[arch=*]&quot; = (
+                                        &quot;-fno-optimize-sibling-calls&quot;,
+                                        &quot;-fno-omit-frame-pointer&quot;,
+                                );
+                                PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO;
+                                PRODUCT_NAME = &quot;$(TARGET_NAME)&quot;;
+                        };
+                        name = Release;
+                };
+                14CC393A18EA811F004AFE34 /* Debug */ = {
+                        isa = XCBuildConfiguration;
+                        buildSettings = {
+                                CLANG_ENABLE_OBJC_ARC = YES;
+                                COMBINE_HIDPI_IMAGES = YES;
+                                EXECUTABLE_PREFIX = lib;
+                                GCC_PREPROCESSOR_DEFINITIONS = (
+                                        &quot;DEBUG=1&quot;,
+                                        &quot;$(inherited)&quot;,
+                                );
+                                GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+                                PRODUCT_NAME = &quot;$(TARGET_NAME)&quot;;
+                        };
+                        name = Debug;
+                };
+                14CC393B18EA811F004AFE34 /* Release */ = {
+                        isa = XCBuildConfiguration;
+                        buildSettings = {
+                                CLANG_ENABLE_OBJC_ARC = YES;
+                                COMBINE_HIDPI_IMAGES = YES;
+                                EXECUTABLE_PREFIX = lib;
+                                GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+                                PRODUCT_NAME = &quot;$(TARGET_NAME)&quot;;
+                        };
+                        name = Release;
+                };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+                14452CA4177D24460097E057 /* Build configuration list for PBXProject &quot;MallocBench&quot; */ = {
+                        isa = XCConfigurationList;
+                        buildConfigurations = (
+                                14452CB5177D24460097E057 /* Debug */,
+                                14452CB6177D24460097E057 /* Release */,
+                        );
+                        defaultConfigurationIsVisible = 0;
+                        defaultConfigurationName = Release;
+                };
+                14452CB7177D24460097E057 /* Build configuration list for PBXNativeTarget &quot;MallocBench&quot; */ = {
+                        isa = XCConfigurationList;
+                        buildConfigurations = (
+                                14452CB8177D24460097E057 /* Debug */,
+                                14452CB9177D24460097E057 /* Release */,
+                        );
+                        defaultConfigurationIsVisible = 0;
+                        defaultConfigurationName = Release;
+                };
+                14CC393918EA811F004AFE34 /* Build configuration list for PBXNativeTarget &quot;mbmalloc&quot; */ = {
+                        isa = XCConfigurationList;
+                        buildConfigurations = (
+                                14CC393A18EA811F004AFE34 /* Debug */,
+                                14CC393B18EA811F004AFE34 /* Release */,
+                        );
+                        defaultConfigurationIsVisible = 0;
+                        defaultConfigurationName = Release;
+                };
+/* End XCConfigurationList section */
+        };
+        rootObject = 14452CA1177D24460097E057 /* Project object */;
+}
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchrunmallocbenchmarks"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/run-malloc-benchmarks (0 => 166667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/run-malloc-benchmarks                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/run-malloc-benchmarks        2014-04-02 21:38:49 UTC (rev 166667)
</span><span class="lines">@@ -0,0 +1,347 @@
</span><ins>+#!/usr/bin/env ruby
+
+require 'getoptlong'
+require 'pathname'
+
+$binDir = &quot;#{File.expand_path(File.dirname(__FILE__))}&quot;
+$productDir = `perl -e 'use lib \&quot;#{$binDir}/../../Tools/Scripts\&quot;; use webkitdirs; print productDir()'`
+
+$benchmarks = [
+    &quot;churn&quot;,
+    &quot;churn --parallel&quot;,
+    &quot;list_allocate&quot;,
+    &quot;list_allocate --parallel&quot;,
+    &quot;tree_allocate&quot;,
+    &quot;tree_allocate --parallel&quot;,
+    &quot;tree_churn&quot;,
+    &quot;tree_churn --parallel&quot;,
+    &quot;facebook&quot;,
+    &quot;facebook --parallel&quot;,
+    &quot;fragment&quot;,
+    &quot;fragment --parallel&quot;,
+    &quot;fragment_iterate&quot;,
+    &quot;fragment_iterate --parallel&quot;,
+    &quot;message_one&quot;,
+    &quot;message_many&quot;,
+    &quot;medium&quot;,
+    &quot;medium --parallel&quot;,
+    &quot;big&quot;,
+    &quot;big --parallel&quot;,
+]
+
+$heap = 0
+$measureHeap = false
+
+def usage
+        puts &quot;run-malloc-benchmarks [options] &lt;Name:/path/to/dylib&gt; [&lt;Name:/path/to/dylib&gt;]&quot;
+        puts
+        puts &quot;    Runs a suite of memory allocation and access benchmarks.&quot;
+    puts
+    puts &quot;    &lt;Name:/path/to/dylib&gt; is a symbolic name followed by a folder containing a libmbmalloc.dylib.&quot;
+    puts
+    puts &quot;    Specify \&quot;SystemMalloc\&quot; to test the built-in libc malloc.&quot;
+    puts &quot;    Specify \&quot;NanoMalloc\&quot; to test the built-in libc malloc using the NanoMalloc zone.&quot;
+    puts
+    puts &quot;    Example usage:&quot;
+    puts
+    puts &quot;        run-malloc-benchmarks SystemMalloc NanoMalloc&quot;
+    puts &quot;        run-malloc-benchmarks FastMalloc:/path/to/FastMalloc/Build/Products/Release/&quot;
+    puts &quot;        run-malloc-benchmarks --benchmark churn SystemMalloc FastMalloc:/path/to/FastMalloc/Build/Products/Release/&quot;
+    puts
+        puts &quot;Options:&quot;
+    puts
+    puts &quot;    --benchmark &lt;benchmark&gt;      Select a single benchmark to run instead of the full suite.&quot;
+    puts &quot;    --heap &lt;heap&gt;           Set a baseline heap size.&quot;
+    puts
+end
+
+class Dylib
+    attr_reader :name
+    attr_reader :path
+
+    def initialize(name, path)
+        @name = name
+        @path = File.join(path, &quot;libmbmalloc.dylib&quot;)
+    end
+end
+
+class Results
+    attr_reader :executionTime
+    attr_reader :peakMemory
+    attr_reader :memoryAtEnd
+
+    def initialize(executionTime, peakMemory, memoryAtEnd)
+        @executionTime = executionTime
+        @peakMemory = peakMemory
+        @memoryAtEnd = memoryAtEnd
+    end
+end
+
+class Stat
+    attr_reader :benchmark
+    attr_reader :result
+
+    def initialize(benchmark, result)
+        @benchmark = benchmark
+        @result = result[/\d+/].to_i
+    end
+end
+
+class TimeStat &lt; Stat
+    def to_s
+            @result + &quot;ms&quot;
+    end
+end
+
+class MemoryStat &lt; Stat
+    def to_s
+            @result + &quot;kB&quot;
+    end
+end
+
+class PeakMemoryStat &lt; Stat
+    def to_s
+            @result + &quot;kB&quot;
+    end
+end
+
+def lpad(str, chars)
+    if str.length &gt; chars
+        str
+    else
+        &quot;%#{chars}s&quot;%(str)
+    end
+end
+
+def rpad(str, chars)
+    while str.length &lt; chars
+        str += &quot; &quot;
+    end
+    str
+end
+
+def computeArithmeticMean(array)
+  sum = 0.0
+  array.each {
+    | value |
+    sum += value
+  }
+  (sum / array.length)
+end
+
+def computeGeometricMean(array)
+  mult = 1.0
+  array.each {
+    | value |
+    mult *= value ? value : 1.0
+  }
+  (mult ** (1.0 / array.length))
+end
+
+def computeHarmonicMean(array)
+  1.0 / computeArithmeticMean(array.collect{ | value | 1.0 / value })
+end
+
+def lowerIsBetter(a, b, better, worse)
+    if b &lt; a
+        return &quot;^ &quot; + (a.to_f / b.to_f).round(2).to_s + &quot;x &quot; + better
+    end
+
+    if b == a
+        return &quot;&quot;
+    end
+
+    &quot;! &quot; + (b.to_f / a.to_f).round(2).to_s + &quot;x &quot; + worse
+end
+
+
+def lowerIsFaster(a, b)
+    lowerIsBetter(a, b, &quot;faster&quot;, &quot;slower&quot;)
+end
+
+def lowerIsSmaller(a, b)
+    lowerIsBetter(a, b, &quot;smaller&quot;, &quot;bigger&quot;)
+end
+
+def numberWithDelimiter(number)
+    number.to_s.reverse.gsub(/...(?=.)/,'\&amp;,').reverse
+end
+
+def prettify(number, suffix)
+    numberWithDelimiter(number) + suffix
+end
+
+def parseOptions
+    GetoptLong.new(
+        ['--benchmark', GetoptLong::REQUIRED_ARGUMENT],
+        ['--heap', GetoptLong::REQUIRED_ARGUMENT],
+        ['--measure-heap', GetoptLong::NO_ARGUMENT],
+        ['--help', GetoptLong::NO_ARGUMENT],
+    ).each {
+        | opt, arg |
+        case opt
+        when '--benchmark'
+            $benchmarks = [ arg ]
+        when '--heap'
+            $heap = arg
+        when '--measure-heap'
+            $measureHeap = true
+        when '--help'
+            usage
+            exit 1
+        else
+          raise &quot;bad option: #{opt}&quot;
+        end
+    }
+
+    if ARGV.length &lt; 1
+        puts &quot;Error: No dylib specified.&quot;
+        exit 1
+    end
+
+    dylibs = []
+    ARGV.each {
+        | arg |
+        if arg == &quot;SystemMalloc&quot;
+            dylib = Dylib.new(&quot;SystemMalloc&quot;, $productDir)
+        elsif arg == &quot;NanoMalloc&quot;
+            dylib = Dylib.new(&quot;NanoMalloc&quot;, $productDir)
+        else
+            name = arg.split(&quot;:&quot;)[0]
+            path = arg.split(&quot;:&quot;)[1]
+            if !name || name.length &lt; 1 ||
+                !path || path.length &lt; 1
+                puts &quot;Invalid &lt;Name:/path/to/dylib&gt;: '#{arg}'.&quot;
+                exit 1
+            end
+
+            dylib = Dylib.new(name, File.expand_path(path))
+        end
+
+        if !File.exists?(dylib.path)
+            puts &quot;File not found: #{dylib.path}.&quot;
+            exit 1
+        end
+
+        dylibs.push(dylib)
+    }
+    dylibs
+end
+
+def runBenchmarks(dylibs)
+    executionTime = []
+    peakMemory = []
+    memoryAtEnd = []
+
+    $benchmarks.each {
+        | benchmark |
+
+        executionTime.push([])
+        peakMemory.push([])
+        memoryAtEnd.push([])
+
+        dylibs.each {
+            | dylib |
+
+            $stderr.print &quot;\rRUNNING #{dylib.name}: #{benchmark}...                &quot;
+            env = &quot;DYLD_LIBRARY_PATH='#{Pathname.new(dylib.path).dirname}' &quot;
+            if dylib.name == &quot;NanoMalloc&quot;
+                env += &quot;MallocNanoZone=1 &quot;
+            end
+            input = &quot;cd '#{$productDir}'; #{env} '#{$productDir}/MallocBench' --benchmark #{benchmark} --heap #{$heap} #{$measureHeap ? '--measure-heap' : ''}&quot;
+            output =`#{input}`
+            splitOutput = output.split(&quot;\n&quot;)
+
+            executionTime[-1].push(TimeStat.new(benchmark, splitOutput[1]))
+            peakMemory[-1].push(PeakMemoryStat.new(benchmark, splitOutput.length &gt; 3 ? splitOutput[3] : &quot;0&quot;))
+            memoryAtEnd[-1].push(MemoryStat.new(benchmark, splitOutput.length &gt; 2 ? splitOutput[2] : &quot;0&quot;))
+        }
+    }
+    $stderr.print &quot;\r                                                                                \n&quot;
+
+    Results.new(executionTime, peakMemory, memoryAtEnd)
+end
+
+def printResults(dylibs, results)
+    def printHeader(dylibs, fieldSize)
+        print
+        print lpad(&quot;&quot;, fieldSize)
+        print lpad(dylibs[0].name, fieldSize)
+        if dylibs[1]
+            print lpad(dylibs[1].name, fieldSize)
+            print lpad(&quot;Δ&quot;, fieldSize * 1.25)
+        end
+        print &quot;\n&quot;
+    end
+
+    def printMetric(name, results, compareFunction, suffix, fieldSize)
+        def printMean(name, results, meanFunction, compareFunction, suffix, fieldSize)
+            means = []
+
+            means.push(meanFunction.call(results.collect { | stats | stats[0].result }))
+            print rpad(&quot;    &quot; + name, fieldSize)
+            print lpad(&quot;#{prettify(means[0].round, suffix)}&quot;, fieldSize)
+
+            if results[0][1]
+                means.push(meanFunction.call(results.collect { | stats | stats[1].result }))
+                print lpad(&quot;#{prettify(means[1].round, suffix)}&quot;, fieldSize)
+                print lpad(compareFunction.call(means[0], means[1]), fieldSize * 1.25)
+            end
+
+            print &quot;\n&quot;
+        end
+
+        if results[0][0].result == 0
+            return
+        end
+
+        print name + &quot;:\n&quot;
+        results.each {
+            | stats |
+
+            print rpad(&quot;    &quot; + stats[0].benchmark, fieldSize)
+            print lpad(&quot;#{prettify(stats[0].result, suffix)}&quot;, fieldSize)
+
+            if stats[1]
+                print lpad(&quot;#{prettify(stats[1].result, suffix)}&quot;, fieldSize)
+                print lpad(compareFunction.call(stats[0].result, stats[1].result), fieldSize * 1.25)
+            end
+
+            print &quot;\n&quot;
+        }
+
+        print &quot;\n&quot;
+
+        printMean(&quot;&lt;geometric mean&gt;&quot;, results, method(:computeGeometricMean), compareFunction, suffix, fieldSize)
+        printMean(&quot;&lt;arithmetic mean&gt;&quot;, results, method(:computeArithmeticMean), compareFunction, suffix, fieldSize)
+        printMean(&quot;&lt;harmonic mean&gt;&quot;, results, method(:computeHarmonicMean), compareFunction, suffix, fieldSize)
+
+        print &quot;\n&quot;
+    end
+
+    fieldSize = ($benchmarks + [&quot;&lt;arithmetic mean&gt;&quot;]).collect {
+        | benchmark |
+        benchmark.size
+    }.max + 4
+
+    printHeader(dylibs, fieldSize)
+    printMetric(&quot;Execution Time&quot;, results.executionTime, method(:lowerIsFaster), &quot;ms&quot;, fieldSize)
+    printMetric(&quot;Peak Memory&quot;, results.peakMemory, method(:lowerIsSmaller), &quot;kB&quot;, fieldSize)
+    printMetric(&quot;Memory at End&quot;, results.memoryAtEnd, method(:lowerIsSmaller), &quot;kB&quot;, fieldSize)
+end
+
+def main
+    begin
+        dylibs = parseOptions()
+        results = runBenchmarks(dylibs)
+        printResults(dylibs, results)
+    rescue =&gt; exception
+        puts
+        puts
+        puts exception
+        puts exception.backtrace
+        puts
+    end
+end
+
+main()
</ins><span class="cx">Property changes on: trunk/PerformanceTests/MallocBench/run-malloc-benchmarks
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnexecutable"></a>
<div class="addfile"><h4>Added: svn:executable</h4></div>
</div>

</body>
</html>