Search code examples
batch-fileanacondaprofilingpython-extensionsintel-vtune

How to write a simple VTune wrapper script on Windows?


Question

How do I write a wrapper script for VTune for Windows?

The documentation provides a simple wrapper script example for bash:

#!/bin/bash

# Prefix script
echo "Target process PID: $VTUNE_TARGET_PID"

# Run VTune collector
"$@"

# Postfix script
ls -la $VTUNE_RESULT_DIR

However, on Windows this does not work, of course. I know how to write a batch script with the things I want do prior to the program. However, I fail to formulate the Run VTune collector part for batch files.

The documentation says

use "$@" or "$*" to pass all arguments into the script and start VTune Profiler collection in this environment

Neither %%@%%, %%*%%, %%$@%%, %%$*%% worked ("command not found"). How do I get the profiler to start?

Motivating problem

I want to profile a C++ Python extension in VTune. VTune seems to work quite nicely with python. However, I need to load an anaconda environment prior to calling python. This is what I want to do with the script.


Solution

  • The Windows equivalent of bash's $@ is %*.