# How to profile Swift benchmarks in Instruments

**URL:** <https://forums.swift.org/t/how-to-profile-swift-benchmarks-in-instruments/24267>\
**Category:** Compiler\
**Tags:** benchmarks, wiki\
**Created:** [May 7, 2019, 8:52pm UTC](https://forums.swift.org/t/how-to-profile-swift-benchmarks-in-instruments/24267 "2019-05-07T20:52:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![palimondo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/palimondo/32/1144_2.png) [@palimondo](https://forums.swift.org/u/palimondo)\
**Post date:** [May 7, 2019, 8:52pm UTC](https://forums.swift.org/t/how-to-profile-swift-benchmarks-in-instruments/24267/1 "2019-05-07T20:52:47Z")

</div>

I was asked this question via DMs and thought the answer might be useful for more people:

When profiling individual benchmarks I'll do the following:

1. Open **Instruments** ,
2. Choose **Time Profiler** template,
3. Choose **Target** , navigate to **`Benchmark_O`** binary  
(mine is built in `/Users/mondo/Developer/swift-source/build/Ninja-Release/swift-macosx-x86_64/bin` )
4. Specify command line **Arguments** ,  
eg: `--num-iters=1 --num-samples=2000 AngryPhonebook`
5. **Record Trace**

---

<div class="post-metadata">

**Author:** ![Michael\_Gottesman](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/michael_gottesman/32/280_2.png) [@Michael\_Gottesman](https://forums.swift.org/u/Michael_Gottesman)\
**Post date:** [May 8, 2019, 6:32pm UTC](https://forums.swift.org/t/how-to-profile-swift-benchmarks-in-instruments/24267/2 "2019-05-08T18:32:19Z")

</div>

@palimondo this seems like something that would be useful to add in a document in the benchmark directory. We should also add something that shows how to do analogous perf measurement on Linux (windows, other platforms, etc).

Your thoughts?

---

<div class="post-metadata">

**Author:** ![Michael\_Gottesman](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/michael_gottesman/32/280_2.png) [@Michael\_Gottesman](https://forums.swift.org/u/Michael_Gottesman)\
**Post date:** [May 8, 2019, 6:36pm UTC](https://forums.swift.org/t/how-to-profile-swift-benchmarks-in-instruments/24267/3 "2019-05-08T18:36:50Z")

</div>

It might even make sense to add it to the README since it is such a basic operation.

---

<div class="post-metadata">

**Author:** ![palimondo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/palimondo/32/1144_2.png) [@palimondo](https://forums.swift.org/u/palimondo)\
**Post date:** [May 9, 2019, 8:25pm UTC](https://forums.swift.org/t/how-to-profile-swift-benchmarks-in-instruments/24267/4 "2019-05-09T20:25:56Z")

</div>

Yeah, there was also your unmerged update to benchmarking documentation floating around somewhere... It'll try to get to updating docs together with [RFC: BenchmarkInfo refactoring](https://forums.swift.org/t/rfc-benchmarkinfo-refactoring/20677).
