进行基准测试,可用的基准测试如下:
# List of all available benchmark collections:
sched: Scheduler and IPC benchmarks
syscall: System call benchmarks
mem: Memory access benchmarks
numa: NUMA scheduling and MM benchmarks
futex: Futex stressing benchmarks
epoll: Epoll stressing benchmarks
internals: Perf-internals benchmarks
breakpoint: Breakpoint benchmarks
uprobe: uprobe benchmarks
all: All benchmarks
perf bench sched messaging # 进行调度和IPC的基准
以messaging和pipe为例,测试如下:
# Running sched/messaging benchmark...
# 20 sender and receiver processes per group
# 10 groups == 400 processes run
Total time: 0.194 [sec]
# Running sched/pipe benchmark...
# Executed 1000000 pipe operations between two processes
Total time: 35.578 [sec]
35.578961 usecs/op
28106 ops/sec
进行epoll基准测试,可用的基准测试如下:
# List of available benchmarks for collection 'epoll':
wait: Benchmark epoll concurrent epoll_waits
ctl: Benchmark epoll concurrent epoll_ctls
all: Run all futex benchmarks
# sudo perf bench epoll all
# Running epoll/wait benchmark...
Run summary [PID 357968]: 11 threads monitoring on 64 file-descriptors for 8 secs.
[thread 0] fdmap: 0x557d2eea5510 ... 0x557d2eea560c [ 80021 ops/sec ]
[thread 1] fdmap: 0x557d2eea5880 ... 0x557d2eea597c [ 79874 ops/sec ]
[thread 2] fdmap: 0x557d2eea5b30 ... 0x557d2eea5c2c [ 80310 ops/sec ]
[thread 3] fdmap: 0x557d2eea5de0 ... 0x557d2eea5edc [ 79049 ops/sec ]
[thread 4] fdmap: 0x557d2eea6090 ... 0x557d2eea618c [ 82907 ops/sec ]
[thread 5] fdmap: 0x557d2eea6340 ... 0x557d2eea643c [ 80256 ops/sec ]
[thread 6] fdmap: 0x557d2eea65f0 ... 0x557d2eea66ec [ 80817 ops/sec ]
[thread 7] fdmap: 0x557d2eea68a0 ... 0x557d2eea699c [ 80397 ops/sec ]
[thread 8] fdmap: 0x557d2eea6b50 ... 0x557d2eea6c4c [ 80050 ops/sec ]
[thread 9] fdmap: 0x557d2eea6e00 ... 0x557d2eea6efc [ 81152 ops/sec ]
[thread 10] fdmap: 0x557d2eea70b0 ... 0x557d2eea71ac [ 79548 ops/sec ]
Averaged 80398 operations/sec (+- 0.38%), total secs = 8
# Running epoll/ctl benchmark...
Run summary [PID 350193]: 12 threads doing epoll_ctl ops 64 file-descriptors for 8 secs.
[thread 0] fdmap: 0x563d1dd15b50 ... 0x563d1dd15c4c [ add: 189312 ops; mod: 189312 ops; del: 189312 ops ]
[thread 1] fdmap: 0x563d1dd15e00 ... 0x563d1dd15efc [ add: 185024 ops; mod: 185024 ops; del: 185024 ops ]
[thread 2] fdmap: 0x563d1dd160b0 ... 0x563d1dd161ac [ add: 199872 ops; mod: 199872 ops; del: 199872 ops ]
[thread 3] fdmap: 0x563d1dd16b30 ... 0x563d1dd16c2c [ add: 203200 ops; mod: 203200 ops; del: 203200 ops ]
[thread 4] fdmap: 0x563d1dd16de0 ... 0x563d1dd16edc [ add: 203776 ops; mod: 203776 ops; del: 203776 ops ]
[thread 5] fdmap: 0x563d1dd17090 ... 0x563d1dd1718c [ add: 199424 ops; mod: 199424 ops; del: 199424 ops ]
[thread 6] fdmap: 0x563d1dd173e0 ... 0x563d1dd174dc [ add: 202944 ops; mod: 202944 ops; del: 202944 ops ]
[thread 7] fdmap: 0x563d1dd17690 ... 0x563d1dd1778c [ add: 199488 ops; mod: 199488 ops; del: 199488 ops ]
[thread 8] fdmap: 0x563d1dd17940 ... 0x563d1dd17a3c [ add: 197312 ops; mod: 197312 ops; del: 197312 ops ]
[thread 9] fdmap: 0x563d1dd17bf0 ... 0x563d1dd17cec [ add: 198720 ops; mod: 198720 ops; del: 198720 ops ]
[thread 10] fdmap: 0x563d1dd17ea0 ... 0x563d1dd17f9c [ add: 190144 ops; mod: 190144 ops; del: 190144 ops ]
[thread 11] fdmap: 0x563d1dd18150 ... 0x563d1dd1824c [ add: 190784 ops; mod: 190784 ops; del: 190784 ops ]
Averaged 196666 ADD operations (+- 0.92%)
Averaged 196666 MOD operations (+- 0.92%)
Averaged 196666 DEL operations (+- 0.92%)
进行内存基准测试,可用的基准测试如下:
# List of available benchmarks for collection 'mem':
memcpy: Benchmark for memcpy() functions
memset: Benchmark for memset() functions
find_bit: Benchmark for find_bit() functions
all: Run all memory access benchmarks