From nobody Fri Dec 19 18:53:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608305617; cv=none; d=zohomail.com; s=zohoarc; b=ZDRRoJGi8+yGNK2Qq6Ghr82PWJg2gZSM1F14kaUSYJZuApWtVelrJLepFxJW/vbLFmF/QHMQp/1I7tBY5T8XehDNxy9NsodULD8cN9u9pe8S9qkpmL6dWI14CglPbH0bx79QRmwk9ZuaPqqBG3dYOA3HsdL+qrX9JjPat5BOnns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608305617; h=Content-Type: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=z3lKdk1VphxgXZtQrQQx5saPGM0quIsvXrGGU8V7EYc=; b=ZOQwhPMIDKYlxqvWhceNIRK/7XqSPR0xkozzXRpISRApLqM7RUgh5+9UL4qEwc8mbsOrlEod8JS7QsL0C6NkBRxYYhMPtF01yaad0Ygk8Aa6Gw/UN+4hS9QIsVwPN/Wpn6jHIur4bmW1KniT7EJGRSwFEuyuEQofdRHSNviTVLQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1608305617106632.2123023837261; Fri, 18 Dec 2020 07:33:37 -0800 (PST) Received: from localhost ([::1]:39266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHl9-0000wT-NA for importer@patchew.org; Fri, 18 Dec 2020 10:33:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHS1-0002ky-WF for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56943) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRx-0005Wa-Q9 for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:48 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-109-kn1f6d4mORuRwu7-dVPFgA-1; Fri, 18 Dec 2020 10:13:41 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 73B81801817; Fri, 18 Dec 2020 15:13:39 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1DAF5D769; Fri, 18 Dec 2020 15:13:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304425; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z3lKdk1VphxgXZtQrQQx5saPGM0quIsvXrGGU8V7EYc=; b=dgE0TaSFUdvjJ8JpaWjzX4rrXkAsuJiLMvwseSFjxvzN4X0Xhax+xeGyoVJwctB8jI15aF cYQGCYDkPkt3oc/8z6A6UawXkGVTG4wwLeRmqxbNdIj07FyFCIxgipQHMbBih4PUw5eqKM n1WEfscK50ZtE9ZpdjwNjkKKB17acs4= X-MC-Unique: kn1f6d4mORuRwu7-dVPFgA-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 21/30] simplebench: move results_to_text() into separate file Date: Fri, 18 Dec 2020 16:12:40 +0100 Message-Id: <20201218151249.715731-22-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Let's keep view part in separate: this way it's better to improve it in the following commits. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201021145859.11201-18-vsementsov@virtuozzo.com> Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- scripts/simplebench/bench-example.py | 3 +- scripts/simplebench/bench_write_req.py | 3 +- scripts/simplebench/results_to_text.py | 48 ++++++++++++++++++++++++++ scripts/simplebench/simplebench.py | 31 ----------------- 4 files changed, 52 insertions(+), 33 deletions(-) create mode 100644 scripts/simplebench/results_to_text.py diff --git a/scripts/simplebench/bench-example.py b/scripts/simplebench/ben= ch-example.py index f24cf22fe9..d9c7f7bc17 100644 --- a/scripts/simplebench/bench-example.py +++ b/scripts/simplebench/bench-example.py @@ -19,6 +19,7 @@ # =20 import simplebench +from results_to_text import results_to_text from bench_block_job import bench_block_copy, drv_file, drv_nbd =20 =20 @@ -77,4 +78,4 @@ test_envs =3D [ ] =20 result =3D simplebench.bench(bench_func, test_envs, test_cases, count=3D3) -print(simplebench.results_to_text(result)) +print(results_to_text(result)) diff --git a/scripts/simplebench/bench_write_req.py b/scripts/simplebench/b= ench_write_req.py index e175bcd7a4..da601ea2fe 100755 --- a/scripts/simplebench/bench_write_req.py +++ b/scripts/simplebench/bench_write_req.py @@ -26,6 +26,7 @@ import sys import os import subprocess import simplebench +from results_to_text import results_to_text =20 =20 def bench_func(env, case): @@ -167,4 +168,4 @@ if __name__ =3D=3D '__main__': =20 result =3D simplebench.bench(bench_func, test_envs, test_cases, count= =3D3, initial_run=3DFalse) - print(simplebench.results_to_text(result)) + print(results_to_text(result)) diff --git a/scripts/simplebench/results_to_text.py b/scripts/simplebench/r= esults_to_text.py new file mode 100644 index 0000000000..58d909ffd9 --- /dev/null +++ b/scripts/simplebench/results_to_text.py @@ -0,0 +1,48 @@ +# 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 result_to_text(result): + """Return text representation of bench_one() returned dict.""" + if 'average' in result: + s =3D '{:.2f} +- {:.2f}'.format(result['average'], result['stdev']) + if 'n-failed' in result: + s +=3D '\n({} failed)'.format(result['n-failed']) + return s + else: + return 'FAILED' + + +def results_to_text(results): + """Return text representation of bench() returned dict.""" + from tabulate import tabulate + + dim =3D None + tab =3D [[""] + [c['id'] for c in results['envs']]] + for case in results['cases']: + row =3D [case['id']] + for env in results['envs']: + res =3D results['tab'][case['id']][env['id']] + if dim is None: + dim =3D res['dimension'] + else: + assert dim =3D=3D res['dimension'] + row.append(result_to_text(res)) + tab.append(row) + + return f'All results are in {dim}\n\n' + tabulate(tab) diff --git a/scripts/simplebench/simplebench.py b/scripts/simplebench/simpl= ebench.py index aa74b78a04..f61513af90 100644 --- a/scripts/simplebench/simplebench.py +++ b/scripts/simplebench/simplebench.py @@ -79,17 +79,6 @@ def bench_one(test_func, test_env, test_case, count=3D5,= initial_run=3DTrue): return result =20 =20 -def result_to_text(result): - """Return text representation of bench_one() returned dict.""" - if 'average' in result: - s =3D '{:.2f} +- {:.2f}'.format(result['average'], result['stdev']) - 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 =20 @@ -125,23 +114,3 @@ def bench(test_func, test_envs, test_cases, *args, **v= args): =20 print('Done') return results - - -def results_to_text(results): - """Return text representation of bench() returned dict.""" - from tabulate import tabulate - - dim =3D None - tab =3D [[""] + [c['id'] for c in results['envs']]] - for case in results['cases']: - row =3D [case['id']] - for env in results['envs']: - res =3D results['tab'][case['id']][env['id']] - if dim is None: - dim =3D res['dimension'] - else: - assert dim =3D=3D res['dimension'] - row.append(result_to_text(res)) - tab.append(row) - - return f'All results are in {dim}\n\n' + tabulate(tab) --=20 2.29.2