tests: fixes aio-win32 about aio_remove_fd_handler, get it consistence with aio-posix.c
[qemu/ar7.git] / scripts / simplebench / bench-example.py
blobc642a5b89154ca555b842637c4909adf0254ee09
1 #!/usr/bin/env python3
3 # Benchmark example
5 # Copyright (c) 2019 Virtuozzo International GmbH.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 import simplebench
22 from bench_block_job import bench_block_copy, drv_file, drv_nbd
25 def bench_func(env, case):
26 """ Handle one "cell" of benchmarking table. """
27 return bench_block_copy(env['qemu_binary'], env['cmd'],
28 case['source'], case['target'])
31 # You may set the following five variables to correct values, to turn this
32 # example to real benchmark.
33 ssd_source = '/path-to-raw-source-image-at-ssd'
34 ssd_target = '/path-to-raw-target-image-at-ssd'
35 hdd_target = '/path-to-raw-source-image-at-hdd'
36 nbd_ip = 'nbd-ip-addr'
37 nbd_port = 'nbd-port-number'
39 # Test-cases are "rows" in benchmark resulting table, 'id' is a caption for
40 # the row, other fields are handled by bench_func.
41 test_cases = [
43 'id': 'ssd -> ssd',
44 'source': drv_file(ssd_source),
45 'target': drv_file(ssd_target)
48 'id': 'ssd -> hdd',
49 'source': drv_file(ssd_source),
50 'target': drv_file(hdd_target)
53 'id': 'ssd -> nbd',
54 'source': drv_file(ssd_source),
55 'target': drv_nbd(nbd_ip, nbd_port)
59 # Test-envs are "columns" in benchmark resulting table, 'id is a caption for
60 # the column, other fields are handled by bench_func.
61 test_envs = [
63 'id': 'backup-1',
64 'cmd': 'blockdev-backup',
65 'qemu_binary': '/path-to-qemu-binary-1'
68 'id': 'backup-2',
69 'cmd': 'blockdev-backup',
70 'qemu_binary': '/path-to-qemu-binary-2'
73 'id': 'mirror',
74 'cmd': 'blockdev-mirror',
75 'qemu_binary': '/path-to-qemu-binary-1'
79 result = simplebench.bench(bench_func, test_envs, test_cases, count=3)
80 print(simplebench.ascii(result))