Profile swift on Windows?

Hello,

I was curious to know if, as the title said, there is any way to profile Swift code on Windows.

Many thanks.

1 Like

I was curious about this myself. Been working through the tinyrenderer project (GitHub - ssloy/tinyrenderer: A brief computer graphics / rendering course) and wanted to profile some of the code. It is possible. Assuming you're using swiftpm, build your project with this command line:

swift build -c release -debug-info-format=codeview

Where -c release builds with optimisations enabled, and -debug-info-format=codeview generates PDBs.

Next, open Visual Studio with no code. Go Debug and choose Performance Profiler.... Choose an executable target:

image

Choose the executable under the .build\x86_64-unknown-windows-msvc\release directory. (It should have a PDB as well an EXE in there.) Profile as you would normally, choosing CPU Profiler. All going well, you should be able to see function names, and hotspots just like you were debugging C++ code:

7 Likes

Thank you.

I didn't try yet but I will as soon as I can