]> git.proxmox.com Git - mirror_qemu.git/blob - scripts/simplebench/bench-example.py
bugfix: hostmem: Free host_nodes list right after visited
[mirror_qemu.git] / scripts / simplebench / bench-example.py
1 #!/usr/bin/env python3
2 #
3 # Benchmark example
4 #
5 # Copyright (c) 2019 Virtuozzo International GmbH.
6 #
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.
11 #
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.
16 #
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/>.
19 #
20
21 import simplebench
22 from bench_block_job import bench_block_copy, drv_file, drv_nbd
23
24
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'])
29
30
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'
38
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 = [
42 {
43 'id': 'ssd -> ssd',
44 'source': drv_file(ssd_source),
45 'target': drv_file(ssd_target)
46 },
47 {
48 'id': 'ssd -> hdd',
49 'source': drv_file(ssd_source),
50 'target': drv_file(hdd_target)
51 },
52 {
53 'id': 'ssd -> nbd',
54 'source': drv_file(ssd_source),
55 'target': drv_nbd(nbd_ip, nbd_port)
56 },
57 ]
58
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 = [
62 {
63 'id': 'backup-1',
64 'cmd': 'blockdev-backup',
65 'qemu_binary': '/path-to-qemu-binary-1'
66 },
67 {
68 'id': 'backup-2',
69 'cmd': 'blockdev-backup',
70 'qemu_binary': '/path-to-qemu-binary-2'
71 },
72 {
73 'id': 'mirror',
74 'cmd': 'blockdev-mirror',
75 'qemu_binary': '/path-to-qemu-binary-1'
76 }
77 ]
78
79 result = simplebench.bench(bench_func, test_envs, test_cases, count=3)
80 print(simplebench.ascii(result))