How to programmatically determine fixed CPU frequency for memory latency benchmarking on Apple Silicon?

Hi everyone,

I am developing a benchmarking tool to measure memory latency (L1/L2/DRAM) on Apple Silicon. I am currently using Xcode Instruments (CPU Counters) to validate my results.

In my latest run for a 128 MB buffer with random access, Instruments shows:

Latency (cycles): ~259 cycles (derived from LDST_UNIT_OLD_L1D_CACHE_MISS / L1D_CACHE_MISS_LD).

Manual Timer Result: ~80 ns.

To correlate these two values, I need the exact CPU Frequency (GHz) at the time of the sample.

My Questions:

Is there a recommended way to programmatically fetch the current frequency of the Performance cores (p-cores) during a benchmark run?

Does Apple provide a "nominal" frequency value for M-series chips that we should use for cycle-to-nanosecond conversions?

In Instruments, is there a hidden counter or "Average Frequency" metric that I can enable to avoid manual math?

Hardware/Software Environment:

Tool: Instruments 26.3+ (CPU Counters Template).

Chip: A19, iPhone 17 pro.

OS: 26.3.

How to programmatically determine fixed CPU frequency for memory latency benchmarking on Apple Silicon?
 
 
Q