From nobody Tue May 14 18:07:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1582874432; cv=none; d=zohomail.com; s=zohoarc; b=ZLjVX5fjhj+dC1yQdmX/QYNlpNpnLs8P+SOuWlKK49Xity2Dr6f9D9VamwVgT1aJz2d0lmX1jU3nhfD1TR/EmAWfgAGAnWl1kX+jRrAnTG3zYmz7yUxbXitLi0QkuG0Swa7YL84qqh528kubh3vjhkni98gbI7TKFH0C3AqeMf4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582874432; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bR2sHK0BFpNIBKHP5o/RgoGOVg3pP4SjmYUJCVzgA/g=; b=QL4sYWRgz70urgpR5yKqeIbkwFoepoXEh1rijlvVpvm5xLUXmB5Nlg9SRN+iY6GvB+WLGTCspMIzX7s+mhpv1lTAxTzu054KOQCCZURp1o1mUzn5W+4JK+YsoM4oHDsmY09sLZePvEuxxbwhoadBWCdOB1Z0EdBSKOR1e5JR+c4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582874432804377.40468058056274; Thu, 27 Feb 2020 23:20:32 -0800 (PST) Received: from localhost ([::1]:42646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7Zwl-0004Vp-JT for importer@patchew.org; Fri, 28 Feb 2020 02:20:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33408) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7Zvm-0002Zh-Ij for qemu-devel@nongnu.org; Fri, 28 Feb 2020 02:19:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7Zvl-00061H-02 for qemu-devel@nongnu.org; Fri, 28 Feb 2020 02:19:30 -0500 Received: from relay.sw.ru ([185.231.240.75]:51950) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7Zvk-00060d-OQ; Fri, 28 Feb 2020 02:19:28 -0500 Received: from vovaso.qa.sw.ru ([10.94.3.0] helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1j7Zve-0002hc-9x; Fri, 28 Feb 2020 10:19:22 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Subject: [PATCH v3 1/4] scripts/simplebench: add simplebench.py Date: Fri, 28 Feb 2020 10:19:11 +0300 Message-Id: <20200228071914.11746-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200228071914.11746-1-vsementsov@virtuozzo.com> References: <20200228071914.11746-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, ehabkost@redhat.com, qemu-block@nongnu.org, stefanha@gmail.com, mreitz@redhat.com, crosa@redhat.com, den@openvz.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Add simple benchmark table creator. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Aleksandar Markovic --- scripts/simplebench/simplebench.py | 128 +++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 scripts/simplebench/simplebench.py diff --git a/scripts/simplebench/simplebench.py b/scripts/simplebench/simpl= ebench.py new file mode 100644 index 0000000000..59e7314ff6 --- /dev/null +++ b/scripts/simplebench/simplebench.py @@ -0,0 +1,128 @@ +#!/usr/bin/env python +# +# Simple benchmarking framework +# +# Copyright (c) 2019 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +def bench_one(test_func, test_env, test_case, count=3D5, initial_run=3DTru= e): + """Benchmark one test-case + + test_func -- benchmarking function with prototype + test_func(env, case), which takes test_env and test_case + arguments and returns {'seconds': int} (which is benchm= ark + result) on success and {'error': str} on error. Returned + dict may contain any other additional fields. + test_env -- test environment - opaque first argument for test_func + test_case -- test case - opaque second argument for test_func + count -- how many times to call test_func, to calculate average + initial_run -- do initial run of test_func, which don't get into result + + Returns dict with the following fields: + 'runs': list of test_func results + 'average': average seconds per run (exists only if at least one r= un + succeeded) + 'delta': maximum delta between test_func result and the average + (exists only if at least one run succeeded) + 'n-failed': number of failed runs (exists only if at least one run + failed) + """ + if initial_run: + print(' #initial run:') + print(' ', test_func(test_env, test_case)) + + runs =3D [] + for i in range(count): + print(' #run {}'.format(i+1)) + res =3D test_func(test_env, test_case) + print(' ', res) + runs.append(res) + + result =3D {'runs': runs} + + successed =3D [r for r in runs if ('seconds' in r)] + if successed: + avg =3D sum(r['seconds'] for r in successed) / len(successed) + result['average'] =3D avg + result['delta'] =3D max(abs(r['seconds'] - avg) for r in successed) + + if len(successed) < count: + result['n-failed'] =3D count - len(successed) + + return result + + +def ascii_one(result): + """Return ASCII representation of bench_one() returned dict.""" + if 'average' in result: + s =3D '{:.2f} +- {:.2f}'.format(result['average'], result['delta']) + if 'n-failed' in result: + s +=3D '\n({} failed)'.format(result['n-failed']) + return s + else: + return 'FAILED' + + +def bench(test_func, test_envs, test_cases, *args, **vargs): + """Fill benchmark table + + test_func -- benchmarking function, see bench_one for description + test_envs -- list of test environments, see bench_one + test_cases -- list of test cases, see bench_one + args, vargs -- additional arguments for bench_one + + Returns dict with the following fields: + 'envs': test_envs + 'cases': test_cases + 'tab': filled 2D array, where cell [i][j] is bench_one result for + test_cases[i] for test_envs[j] (i.e., rows are test cases= and + columns are test environments) + """ + tab =3D {} + results =3D { + 'envs': test_envs, + 'cases': test_cases, + 'tab': tab + } + n =3D 1 + n_tests =3D len(test_envs) * len(test_cases) + for env in test_envs: + for case in test_cases: + print('Testing {}/{}: {} :: {}'.format(n, n_tests, + env['id'], case['id'])) + if case['id'] not in tab: + tab[case['id']] =3D {} + tab[case['id']][env['id']] =3D bench_one(test_func, env, case, + *args, **vargs) + n +=3D 1 + + print('Done') + return results + + +def ascii(results): + """Return ASCII representation of bench() returned dict.""" + from tabulate import tabulate + + tab =3D [[""] + [c['id'] for c in results['envs']]] + for case in results['cases']: + row =3D [case['id']] + for env in results['envs']: + row.append(ascii_one(results['tab'][case['id']][env['id']])) + tab.append(row) + + return tabulate(tab) --=20 2.21.0 From nobody Tue May 14 18:07:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1582874426; cv=none; d=zohomail.com; s=zohoarc; b=ZRdWPeIVgVPdYv0vgek8sk3A9RIeI9oOFCeM7j6r34ifHQNsteECUqXCq4x0XSeGQ3x13Q4IKr/S069yURjN7DUPqnWarvqycOwfM+qNn7jacG1ID8GzAdNekahjInsMFjcBSfT5MFywDD/keqRX4UEt2cJtTfe2NYIcpS2h8io= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582874426; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aqsOuPCCw9ePUcvfVBqDls0A9aa+YyZlCgX3lgN+blo=; b=oDYmi0coJf2AlqXxYftVlcvOpwgDdFkSlAbFpAUEGFzbZvoKxxkapf/lhWb2hv2heTa+Vnz5v88eA7a+7ZWnduQaLFmyF/d4f/qBxJmE8SogNFi+2lf97FY//g/MyzDymbAX26I7NTlX7Nwo4+z1iaiDrZJHN/gJ4rQ6bGzbDpA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582874426868374.60908900776303; Thu, 27 Feb 2020 23:20:26 -0800 (PST) Received: from localhost ([::1]:42644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7Zwf-0004Fh-2p for importer@patchew.org; Fri, 28 Feb 2020 02:20:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33399) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7Zvm-0002Zg-8x for qemu-devel@nongnu.org; Fri, 28 Feb 2020 02:19:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7Zvk-000616-Vc for qemu-devel@nongnu.org; Fri, 28 Feb 2020 02:19:30 -0500 Received: from relay.sw.ru ([185.231.240.75]:51944) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7Zvk-00060b-OE; Fri, 28 Feb 2020 02:19:28 -0500 Received: from vovaso.qa.sw.ru ([10.94.3.0] helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1j7Zve-0002hc-DB; Fri, 28 Feb 2020 10:19:22 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Subject: [PATCH v3 2/4] scripts/simplebench: add qemu/bench_block_job.py Date: Fri, 28 Feb 2020 10:19:12 +0300 Message-Id: <20200228071914.11746-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200228071914.11746-1-vsementsov@virtuozzo.com> References: <20200228071914.11746-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, ehabkost@redhat.com, qemu-block@nongnu.org, stefanha@gmail.com, mreitz@redhat.com, crosa@redhat.com, den@openvz.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Add block-job benchmarking helper functions. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Aleksandar Markovic --- scripts/simplebench/bench_block_job.py | 119 +++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100755 scripts/simplebench/bench_block_job.py diff --git a/scripts/simplebench/bench_block_job.py b/scripts/simplebench/b= ench_block_job.py new file mode 100755 index 0000000000..9808d696cf --- /dev/null +++ b/scripts/simplebench/bench_block_job.py @@ -0,0 +1,119 @@ +#!/usr/bin/env python +# +# Benchmark block jobs +# +# Copyright (c) 2019 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +import sys +import os +import socket +import json + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) +from qemu.machine import QEMUMachine +from qemu.qmp import QMPConnectError + + +def bench_block_job(cmd, cmd_args, qemu_args): + """Benchmark block-job + + cmd -- qmp command to run block-job (like blockdev-backup) + cmd_args -- dict of qmp command arguments + qemu_args -- list of Qemu command line arguments, including path to Qe= mu + binary + + Returns {'seconds': int} on success and {'error': str} on failure, dic= t may + contain addional 'vm-log' field. Return value is compatible with + simplebench lib. + """ + + vm =3D QEMUMachine(qemu_args[0], args=3Dqemu_args[1:]) + + try: + vm.launch() + except OSError as e: + return {'error': 'popen failed: ' + str(e)} + except (QMPConnectError, socket.timeout): + return {'error': 'qemu failed: ' + str(vm.get_log())} + + try: + res =3D vm.qmp(cmd, **cmd_args) + if res !=3D {'return': {}}: + vm.shutdown() + return {'error': '"{}" command failed: {}'.format(cmd, str(res= ))} + + e =3D vm.event_wait('JOB_STATUS_CHANGE') + assert e['data']['status'] =3D=3D 'created' + start_ms =3D e['timestamp']['seconds'] * 1000000 + \ + e['timestamp']['microseconds'] + + e =3D vm.events_wait((('BLOCK_JOB_READY', None), + ('BLOCK_JOB_COMPLETED', None), + ('BLOCK_JOB_FAILED', None)), timeout=3DTrue) + if e['event'] not in ('BLOCK_JOB_READY', 'BLOCK_JOB_COMPLETED'): + vm.shutdown() + return {'error': 'block-job failed: ' + str(e), + 'vm-log': vm.get_log()} + end_ms =3D e['timestamp']['seconds'] * 1000000 + \ + e['timestamp']['microseconds'] + finally: + vm.shutdown() + + return {'seconds': (end_ms - start_ms) / 1000000.0} + + +# Bench backup or mirror +def bench_block_copy(qemu_binary, cmd, source, target): + """Helper to run bench_block_job() for mirror or backup""" + assert cmd in ('blockdev-backup', 'blockdev-mirror') + + source['node-name'] =3D 'source' + target['node-name'] =3D 'target' + + return bench_block_job(cmd, + {'job-id': 'job0', 'device': 'source', + 'target': 'target', 'sync': 'full'}, + [qemu_binary, + '-blockdev', json.dumps(source), + '-blockdev', json.dumps(target)]) + + +def drv_file(filename): + return {'driver': 'file', 'filename': filename, + 'cache': {'direct': True}, 'aio': 'native'} + + +def drv_nbd(host, port): + return {'driver': 'nbd', + 'server': {'type': 'inet', 'host': host, 'port': port}} + + +if __name__ =3D=3D '__main__': + import sys + + if len(sys.argv) < 4: + print('USAGE: {} ' + ' ' + ''.format(sys.argv[0])) + exit(1) + + res =3D bench_block_job(sys.argv[1], json.loads(sys.argv[2]), sys.argv= [3:]) + if 'seconds' in res: + print('{:.2f}'.format(res['seconds'])) + else: + print(res) --=20 2.21.0 From nobody Tue May 14 18:07:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1582874509; cv=none; d=zohomail.com; s=zohoarc; b=PN3rD5VjcVLjBWZPRzW4zUNlGleDJysidSktLajs3biaKj2bPBBVbgWRjRC1r4S4IsFoeBERCHhf9nIxljAqgw2oldbybBX+Yc+LLqrQQYOJIb6PGdWPNY2E7HvZb+E8uyix6P6qjplMDIomXXeTEuHxDX4GeVp1FZT3xykvfOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582874509; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=du4NYrIMFwzH4R/JcJ/vvp3to+HptFDyPUdDOJ3+n2c=; b=GaMU0iH8c2gDN2SDM3U0ZWdIFQJgKCOQOi+V8w9x/o3TL3+OiYWLF9NsHJRWRzqa2MWu7EpLBGGz52P8e/VzgbjTp5dQQEs9lY4G6k6yzrX3smo4/jHb28kqsqq/PPFidtFFfvfl037k92aj28aeSEyEpvcmORBOt90SlONDYUQ= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582874509011524.0949911569406; Thu, 27 Feb 2020 23:21:49 -0800 (PST) Received: from localhost ([::1]:42682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7Zxz-0006ov-LW for importer@patchew.org; Fri, 28 Feb 2020 02:21:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33398) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7Zvm-0002Zf-8l for qemu-devel@nongnu.org; Fri, 28 Feb 2020 02:19:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7Zvl-00061U-0K for qemu-devel@nongnu.org; Fri, 28 Feb 2020 02:19:30 -0500 Received: from relay.sw.ru ([185.231.240.75]:51948) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7Zvk-00060e-OS; Fri, 28 Feb 2020 02:19:28 -0500 Received: from vovaso.qa.sw.ru ([10.94.3.0] helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1j7Zve-0002hc-HV; Fri, 28 Feb 2020 10:19:22 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Subject: [PATCH v3 3/4] scripts/simplebench: add example usage of simplebench Date: Fri, 28 Feb 2020 10:19:13 +0300 Message-Id: <20200228071914.11746-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200228071914.11746-1-vsementsov@virtuozzo.com> References: <20200228071914.11746-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, ehabkost@redhat.com, qemu-block@nongnu.org, stefanha@gmail.com, mreitz@redhat.com, crosa@redhat.com, den@openvz.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This example may be used as a template for custom benchmark. It illustrates three things to prepare: - define bench_func - define test environments (columns) - define test cases (rows) And final call of simplebench API. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Aleksandar Markovic --- scripts/simplebench/bench-example.py | 80 ++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 scripts/simplebench/bench-example.py diff --git a/scripts/simplebench/bench-example.py b/scripts/simplebench/ben= ch-example.py new file mode 100644 index 0000000000..c642a5b891 --- /dev/null +++ b/scripts/simplebench/bench-example.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python3 +# +# Benchmark example +# +# Copyright (c) 2019 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import simplebench +from bench_block_job import bench_block_copy, drv_file, drv_nbd + + +def bench_func(env, case): + """ Handle one "cell" of benchmarking table. """ + return bench_block_copy(env['qemu_binary'], env['cmd'], + case['source'], case['target']) + + +# You may set the following five variables to correct values, to turn this +# example to real benchmark. +ssd_source =3D '/path-to-raw-source-image-at-ssd' +ssd_target =3D '/path-to-raw-target-image-at-ssd' +hdd_target =3D '/path-to-raw-source-image-at-hdd' +nbd_ip =3D 'nbd-ip-addr' +nbd_port =3D 'nbd-port-number' + +# Test-cases are "rows" in benchmark resulting table, 'id' is a caption for +# the row, other fields are handled by bench_func. +test_cases =3D [ + { + 'id': 'ssd -> ssd', + 'source': drv_file(ssd_source), + 'target': drv_file(ssd_target) + }, + { + 'id': 'ssd -> hdd', + 'source': drv_file(ssd_source), + 'target': drv_file(hdd_target) + }, + { + 'id': 'ssd -> nbd', + 'source': drv_file(ssd_source), + 'target': drv_nbd(nbd_ip, nbd_port) + }, +] + +# Test-envs are "columns" in benchmark resulting table, 'id is a caption f= or +# the column, other fields are handled by bench_func. +test_envs =3D [ + { + 'id': 'backup-1', + 'cmd': 'blockdev-backup', + 'qemu_binary': '/path-to-qemu-binary-1' + }, + { + 'id': 'backup-2', + 'cmd': 'blockdev-backup', + 'qemu_binary': '/path-to-qemu-binary-2' + }, + { + 'id': 'mirror', + 'cmd': 'blockdev-mirror', + 'qemu_binary': '/path-to-qemu-binary-1' + } +] + +result =3D simplebench.bench(bench_func, test_envs, test_cases, count=3D3) +print(simplebench.ascii(result)) --=20 2.21.0 From nobody Tue May 14 18:07:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1582874425; cv=none; d=zohomail.com; s=zohoarc; b=Vw0WPTWj5w8KIimJXJlRAa98gGqyjBTfD8izFO/InuFULyFKL7r0iuNZc+3Tg3bMTW4/CPa5zMLdVkOSEa9x0D4WybAiMX474utrLhq4UHqrh9/QHXdgKwN2B2X/o6cssI5beTaxuZPphNo9QznyHlD+OcVYJ5zO8twZix/jc6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582874425; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g050q2/IdVsST+TuUVwTOfTSujKkugRc81PxQANhONM=; b=DQkCobh6Nd77uIaxoZK3g6hci37fgFhpLWgBvHNhh+GRdgwYXAmKBbEaAY60XkweRUtFArdFKmEj4J4XC/82OVo0ygizW5ny3F5yYchEmckCSWagN7gyh5fgv8Qf76EQebjBLeeSzcqJ2yBLktrYQ3QBTs27u39/UUzfihPvdLo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158287442572288.62262329021121; Thu, 27 Feb 2020 23:20:25 -0800 (PST) Received: from localhost ([::1]:42642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7Zwd-0004Ad-Mz for importer@patchew.org; Fri, 28 Feb 2020 02:20:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33386) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7Zvl-0002Zc-U4 for qemu-devel@nongnu.org; Fri, 28 Feb 2020 02:19:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7Zvl-00061K-0A for qemu-devel@nongnu.org; Fri, 28 Feb 2020 02:19:29 -0500 Received: from relay.sw.ru ([185.231.240.75]:51940) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7Zvk-00060a-P1; Fri, 28 Feb 2020 02:19:28 -0500 Received: from vovaso.qa.sw.ru ([10.94.3.0] helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1j7Zve-0002hc-JY; Fri, 28 Feb 2020 10:19:22 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Subject: [PATCH v3 4/4] MAINTAINERS: add simplebench Date: Fri, 28 Feb 2020 10:19:14 +0300 Message-Id: <20200228071914.11746-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200228071914.11746-1-vsementsov@virtuozzo.com> References: <20200228071914.11746-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, ehabkost@redhat.com, qemu-block@nongnu.org, stefanha@gmail.com, mreitz@redhat.com, crosa@redhat.com, den@openvz.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Aleksandar Markovic --- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 5e5e3e52d6..16d069adc5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2038,6 +2038,11 @@ F: python/qemu/*py F: scripts/*.py F: tests/*.py =20 +Benchmark util +M: Vladimir Sementsov-Ogievskiy +S: Maintained +F: scripts/simplebench/ + QAPI M: Markus Armbruster M: Michael Roth --=20 2.21.0