]> git.saurik.com Git - apple/xnu.git/blame - tests/vm/perf_helpers.h
xnu-7195.81.3.tar.gz
[apple/xnu.git] / tests / vm / perf_helpers.h
CommitLineData
f427ee49
A
1#ifndef VM_PERF_HELPERS_H
2#define VM_PERF_HELPERS_H
3
4/*
5 * Utility functions and constants used by the VM perf tests.
6 */
7#include <inttypes.h>
8#include <time.h>
9#include <stdbool.h>
10
11/*
12 * mmap an anonymous chunk of memory.
13 */
14unsigned char *mmap_buffer(size_t size);
15/*
16 * Returns a - b in microseconds.
17 * NB: a must be >= b
18 */
19uint64_t timespec_difference_us(const struct timespec* a, const struct timespec* b);
20/*
21 * Print the message to stdout along with the current time.
22 * Also flushes stdout so that the log can help detect hangs. Don't call
23 * this function from within the measured portion of the benchmark as it will
24 * pollute your measurement.
25 *
26 * NB: Will only log if verbose == true.
27 */
28void benchmark_log(bool verbose, const char *restrict fmt, ...) __attribute__((format(printf, 2, 3)));
29
30static const uint64_t kNumMicrosecondsInSecond = 1000UL * 1000;
31static const uint64_t kNumNanosecondsInMicrosecond = 1000UL;
32static const uint64_t kNumNanosecondsInSecond = kNumNanosecondsInMicrosecond * kNumMicrosecondsInSecond;
33
34#endif /* !defined(VM_PERF_HELPERS_H) */