A fairly wide range of metrics can be captured by the benchmarks - most metrics are avilable on both macOS and Linux, but a few are not easily obtained and will thus not yield results on that platform, even if specified.
Currently supported metrics are:
cpuUser
- CPU user space time spent for running the testcpuSystem
- CPU system time spent for running the testcpuTotal
- CPU total time spent for running the test (system + user)wallClock
- Wall clock time for running the testthroughput
- The throughput in operations / secondpeakMemoryResident
- The resident memory usage - sampled during runtimepeakMemoryVirtual
- The virtual memory usage - sampled during runtimemallocCountSmall
- The number of small malloc calls according to jemallocmallocCountLarge
- The number of large malloc calls according to jemallocmallocCountTotal
- The total number of mallocs according to jemallocallocatedResidentMemory
- The amount of allocated resident memory by the application (not including allocator metadata overhead etc) according to jemallocmemoryLeaked
-The number of small+large mallocs - small+large frees in resident memory (just a possible leak)syscalls
- The number of syscalls made during the test -- macOS onlycontextSwitches
- The number of context switches made during the test -- macOS onlythreads
- The maximum number of threads in the process under the test (not exact, sampled)threadsRunning
- The maximum number of threads actually running under the test (not exact, sampled) -- macOS onlyreadSyscalls
- The number of I/O read syscalls performed e.g. read(2) / pread(2) -- Linux onlywriteSyscalls
- The number of I/O write syscalls performed e.g. write(2) / pwrite(2) -- Linux onlyreadBytesLogical
- The number of bytes read from storage (but may be satisfied by pagecache!) -- Linux onlywriteBytesLogical
- The number bytes written to storage (but may be cached) -- Linux onlyreadBytesPhysical
- The number of bytes physically read from a block device (i.e. disk) -- Linux onlywriteBytesPhysical
- The number of bytes physicall written to a block device (i.e. disk) -- Linux only
Additionally, custom metrics are supported custom(_ name: String, polarity: Polarity = .prefersSmaller)
as outlined in the writing benchmarks documentation.
For comparison (swift package benchmark compare
) operations, there's a set of default thresholds that are used which are fairly strict. It is also possible to define both absolute and relative thresholds, per metric, that will be used for such comparisons (or that a given metric should be skipped completely).
See the "writing benchmarks" documentation or look at the sample code to see how custom thresholds can be set up.