<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>how_to_profile.md - fork/rust_serialization_benchmark @ master</title>
<meta name="description" content="how_to_profile.md in fork/rust_serialization_benchmark at master.">
<meta property="og:title" content="how_to_profile.md - fork/rust_serialization_benchmark @ master">
<meta property="og:description" content="how_to_profile.md in fork/rust_serialization_benchmark at master.">
<meta property="og:type" content="website">
<meta property="og:site_name" content="git.julia.blue">
<link rel="stylesheet" href="/css/style.css?v=62">
<script type="module" src="/js/main.js?v=62"></script>
</head>
<body>
<main data-ref="master" data-tip="c26f391a2f136fefa0410bc3b2dd471569587035">
<noscript>
  <div class="callout">
    <p>
      hey! this is a static git repo viewer. commit diffs, file history,
      older commits and other revisions won't load without javascript.
    </p>
    <p>
      you are still able to view source files on branch/tag tips,
      but the experience is degraded.
    </p>
  </div>
</noscript>
<header class="repo"><div>
<h1>fork/rust_serialization_benchmark</h1>
</div>
<pre class="clone">git clone https://git.julia.blue/fork/rust_serialization_benchmark</pre>
</header>
<p class="snapshot-commit"><span class="commit-author">Julia Ryan</span><span class="commit-message" data-commit="c26f391a2f136fefa0410bc3b2dd471569587035">WIP: binrw</span><span class="snapshot-sha sha" data-commit="c26f391a2f136fefa0410bc3b2dd471569587035">c26f391</span><time datetime="2024-12-09T14:34:34-08:00" title="2024-12-09 14:34:34 -0800">2024-12-09</time></p>
<header class="topbar"><details class="switcher"><summary>master</summary><div class="menu"><strong>branches</strong><a href="/fork/rust_serialization_benchmark/ref/bebop/">bebop</a><a href="/fork/rust_serialization_benchmark/ref/gh-pages/">gh-pages</a><a class="current" href="/fork/rust_serialization_benchmark/ref/master/">master</a><a class="all" href="/fork/rust_serialization_benchmark/refs">all refs →</a></div></details><nav class="crumbs"><a href="/fork/rust_serialization_benchmark/">rust_serialization_benchmark</a> / <span class="cur">how_to_profile.md</span></nav>
<span class="view-stats"><span>1.3 KiB</span><span>32 lines</span></span><span class="actions"><a class="raw" href="/fork/rust_serialization_benchmark/raw/aef20a60813b2d20d30616ac446278a73f594b70/how_to_profile.md">raw</a></span></header>
<div class="markdown-view"><input type="radio" name="markdown-view" id="markdown-rendered" checked><label for="markdown-rendered">rendered</label><input type="radio" name="markdown-view" id="markdown-code"><label for="markdown-code">code</label><section class="readme rendered"><h1>How to profile these benchmarks</h1>
<h2>Windows</h2>
<p>We'll be profiling these benchmarks with Visual Studio. Make sure you have basic C/C++ payloads
installed for it.</p>
<ol>
<li>Add the following beneath the <code>[[bench]]</code> line in <code>Cargo.toml</code>:<pre>[profile.bench]
debug = true
</pre>
</li>
<li>Build the benchmark without running it with <code>cargo bench --no-run</code></li>
<li>Locate the benchmark binary at <code>target/release/deps/bench-*.exe</code>. If there are multiple <code>bench</code>
executables in <code>deps</code>, you can determine which one is the most recent by deleting all of them and
rebuilding.</li>
<li>Start Visual Studio and open a new project. Browse to the <code>.exe</code> location and open it.</li>
<li>Right click on the <code>bench-*</code> project in the Solution Explorer and select <code>Properties</code>.</li>
<li>Set the <code>Arguments</code> parameter to <code>--bench &lt;FILTER&gt;</code> where <code>&lt;FILTER&gt;</code> is the filter you would pass
to <code>cargo bench -- &lt;FILTER&gt;</code>.</li>
<li>Save the project properties and select <code>Debug &gt; Performance Profiler...</code>.</li>
<li>Check <code>CPU Usage</code> and click <code>Start</code>. The benchmarks will run and upon finishing the data will be
analyzed.</li>
<li>Select the areas of the diagnostics session when your benchmark is running to analyze.</li>
</ol>
<h2>Linux / MacOS</h2>
<p>TODO: cargo-flamegraph + cgdiff</p>
<h2>Other platforms</h2>
<p>Know how to profile these benchmarks on other platforms? Open a pull request!</p>
</section><div class="code-panel"><pre class="code src language-markdown"><span class="code-line"><a class="ln" id="L1" href="#L1">1</a><span class="code-text"><a-p>#</a-p> <a-tt>How to profile these benchmarks</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L2" href="#L2">2</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L3" href="#L3">3</a><span class="code-text"><a-p>##</a-p> <a-tt>Windows</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L4" href="#L4">4</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L5" href="#L5">5</a><span class="code-text">We&#39;ll be profiling these benchmarks with Visual Studio. Make sure you have basic C/C++ payloads</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L6" href="#L6">6</a><span class="code-text">installed for it.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L7" href="#L7">7</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L8" href="#L8">8</a><span class="code-text"><a-p>1. </a-p>Add the following beneath the `[[bench]]` line in `Cargo.toml`:</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L9" href="#L9">9</a><span class="code-text"><a-p>   </a-p><a-tl>```</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text"><a-p>   </a-p><a-tl>[profile.bench]</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L11" href="#L11">11</a><span class="code-text"><a-p>   </a-p><a-tl>debug = true</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L12" href="#L12">12</a><span class="code-text"><a-p>   ```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L13" href="#L13">13</a><span class="code-text"><a-p>2. </a-p>Build the benchmark without running it with `cargo bench --no-run`</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L14" href="#L14">14</a><span class="code-text"><a-p>3. </a-p>Locate the benchmark binary at `target/release/deps/bench-*.exe`. If there are multiple `bench`</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L15" href="#L15">15</a><span class="code-text"><a-p>   </a-p>executables in `deps`, you can determine which one is the most recent by deleting all of them and</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L16" href="#L16">16</a><span class="code-text"><a-p>   </a-p>rebuilding.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L17" href="#L17">17</a><span class="code-text"><a-p>4. </a-p>Start Visual Studio and open a new project. Browse to the `.exe` location and open it.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L18" href="#L18">18</a><span class="code-text"><a-p>5. </a-p>Right click on the `bench-*` project in the Solution Explorer and select `Properties`.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L19" href="#L19">19</a><span class="code-text"><a-p>6. </a-p>Set the `Arguments` parameter to `--bench &lt;FILTER&gt;` where `&lt;FILTER&gt;` is the filter you would pass</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L20" href="#L20">20</a><span class="code-text"><a-p>   </a-p>to `cargo bench -- &lt;FILTER&gt;`.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L21" href="#L21">21</a><span class="code-text"><a-p>7. </a-p>Save the project properties and select `Debug &gt; Performance Profiler...`.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L22" href="#L22">22</a><span class="code-text"><a-p>8. </a-p>Check `CPU Usage` and click `Start`. The benchmarks will run and upon finishing the data will be</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L23" href="#L23">23</a><span class="code-text"><a-p>   </a-p>analyzed.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L24" href="#L24">24</a><span class="code-text"><a-p>9. </a-p>Select the areas of the diagnostics session when your benchmark is running to analyze.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L25" href="#L25">25</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L26" href="#L26">26</a><span class="code-text"><a-p>## </a-p><a-tt>Linux / MacOS</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L27" href="#L27">27</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L28" href="#L28">28</a><span class="code-text"><a-p>TODO: cargo-flamegraph + cgdiff</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L29" href="#L29">29</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L30" href="#L30">30</a><span class="code-text"><a-p>## </a-p><a-tt>Other platforms</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L31" href="#L31">31</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L32" href="#L32">32</a><span class="code-text">Know how to profile these benchmarks on other platforms? Open a pull request!</span></span></pre></div></div>
</main>
</body>
</html>
