Install "perf" on Mac
As @Sami Laine said in his comment, the Linux perf
tool is dependent on Linux specific code. It relies on the perf_event_open system call which is not standardized.
Note: Maybe you could search how MacOSX users are using recent hardware performance counters.
Instruments app
On macOS you can use the Instruments application to profile your code.
I like to use the "Time Profiler" which will show you how much time your application is its various parts during execution. I haven't used perf myself, but from talks/videos that I've seen this seems to be the most common use.
To use the "Time Profiler":
- Run Instruments, select Time Profiler
- At the top left, select your target (executable).
- Hit the Record button on the top left and let it run for a little while.
- Pause or Stop the execution and drill down on your calls in the main window.
Hope this helps.