1perf_index - This is a tool for gather performance data. perf_index can run in 2two modes. In regulular (offline mode) the usage is: 3pref_index type threads size [args] 4where type is one of the test types explained below, threads is the number of 5userland threads that should preform the task, size is the size of the task and 6args are arguments to pass to the test. Currently only the iperf test requires 7these arguments. For example if run with the following arguments: 8./perf_index cpu 2 100000000 9 10iperf will run the cpu workload on two threads with a total work load size of 11100000000. Since the workload is distributed over 2 threads, on a perfectly 12parallel system, this would take half the time relative to if 1 was specified 13for the threads parameter. When finished running perf_index will write the 14number of seconds it took to standard out as a decimal number. Some of the test 15types have initialization and teardown steps, and these steps are not counted 16towards the time. The workload and the time it takes to be performed differs 17quite drastically between test type, so you may need to play around with the 18size argument to find a value that will complete in a reasonable amount of time. 19 20In online mode, perf_index is invoked like so: 21perf_index remote server 22where remote is exactly the string "remote" and server is the control host to 23connect to. This tells the program to connect to the specified server and wait 24for instructions. The server is run by running the test_controller.py python 25script with the following arguments: 26test_controller.py num_clients type threads size 27The server will wait for num_client to connect. It will then pass type, threads, 28and size to each of those clients, who will run the initialization code and 29report back to the server. Once the initialization is run by every client, the 30server will give the OK to every client to run the workload and begin timing. 31When done, each client reports back to the server. Once the server hears back 32from every client, it will stop timing and output the elapsed time. 33 34 35Test Types: 36Note this implementations are subject to change, for an authoritative source, 37see the source code 38cpu - calculates n md5 sums 39memory - initializes by allocating memory equal to half the RAM on the machine, 40then writes a byte to every page to ensure it is paged in. Then copies n bytes 41from the first half of memory to the second. If the allocated space is less than 42n/2, it keeps repeating the copies until n bytes are copied. 43syscall - calls the getppid(2) system call n times 44fault - performs n page faults by mmaping a large chunk of memory, toggling the 45write protection bit, and writing to each page 46zfod - performs n zero fill on demands, by mmaping a large chunk of memory and 47writing to each page 48file_create - creates n files (in the same directory) with the open(2) system 49call 50file_write - writes n bytes to files on disk. There is one file per each thread. 51file_read - initializes by creating one large file on disk per each thread. 52Then reads n bytes total from all the files. If there are less than n bytes in 53the files, repeats reading from the beginning. 54ram_file_create - same as file_create but on a ram disk 55ram_file_read - same as file_read but on a ram disk 56ram_file_write - same as file_write but on a ram disk 57iperf - uses iperf to send n bytes over the network to the designated host 58specified as args 59compile - compiles xnu using make. This currently does a single compile and 60ignores the size argument 61 62Building: 63perf_index is built automatically by BNI for both Mac (10.9 and later), and iOS 64(7 and later) trains, and is delivered on AppleInternal builds in 65/AppleInternal/CoreOS/perf_index. It is built as part of the xnu_quick_test 66build alias, so you can also find a copy on ~rc at: 67~rc/Software/$RELEASE/Updates/$RELEASEVERSION/Roots/xnu_quick_test/AppleInternal/CoreOS/perf_index. 68 69Alternatively you can build it yourself using make like so: 70SDKROOT=/path/to/sdk make 71 72For example: 73# build for Mac, current OS 74SDKROOT=/ make 75# build for iOS 76SDKROOT=`xcodebuild -sdk iphoneos.internal -version Path` make 77 78By default xnu builds all-way fat, but you can restrict this by explicitly 79specifying architectures like so: 80# build for only armv7 and armv7s 81SDKROOT=`xcodebuild -sdk iphoneos.internal -version Path` make ARCH="armv7 armv7s" 82