This is a simple benchmark that measures the performance of several levels in the memory hierarchy. The basic operation is to store a simple pattern in an array and then verify that the pattern is indeed in the array. This operation is repeated often enough that the ISO standard timing facility can be used to produce about two digits of performance data. This is repeated for arrays whose size is successive powers of two until the array cannot be allocated. A one line report is made after each one of these repetitions. The “step” referred to in the report is the construction of a simple value for an array entry and subsequent recomputation of that value and verification that it is still in the array. Each cache level must be able to hold the entire array to be effective and this program thus provides direct evidence of the speed and size of each cache. Note that the routine clock() returns a value whose units are microseconds but that the actual resolution may be much coarser. The observed resolution is reported as resl=... as the benchmark begins. The time reported is the how long the CPU is allocated to the process. When the array does not fit in available RAM page faults begin and the CPU is not allocated and not counted while the disk does IO. This benchmark does not measure disk performance for that reason.

SUNW,Ultra-5_10: gcc -Wall -O4 bench.c
400 MHz Mac G4, 128MB optimized
Gateway GP7-500, 500 MHz Pentium III CPU, 128MB RAM
Titanium Mac 400MHz 256 MB -O3; with missing L2 cache
G4Mac with OS X 10.3.7 (considerable interference towards end).
IntelMac OS 10.4 1.83 GHz .5GB
IntelMac OS 10.4.8 1.25GB
IntelMac OS 10.5.1 2GB
IntelMac OS 10.5.7 2GB gcc -O3 bench.c -Wall
IntelMac OS 10.6.4 2GB
IntelMac OS 10.8.2 2GB
IntelMac OS 10.9.5 8GB clang bench.c -O3 -Wmost
IntelMac OS 10.11.6 2.7GHz 16GB clang bench.c -O3 -Wmost


2004 December Mods:
If 2 arguments are provided on the command line then the semantics are thus:
./a.out wrds dur
Arguments must be decimal numerals. The program allocates wrds 4 byte words, initializes them, and then waits dur seconds and then verifies them. This repeats. The program will report and stop upon discrepancy. This is useful in detecting either hardware or software memory failure.


2014 December Mods: Made sizes 64 bits long.