From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-971194-garchives=archives.gentoo.org@lists.gentoo.org> Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 69C231396D1 for <garchives@archives.gentoo.org>; Wed, 6 Sep 2017 15:00:58 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BC5ADE0E4B; Wed, 6 Sep 2017 15:00:57 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 9A886E0E4B for <gentoo-commits@lists.gentoo.org>; Wed, 6 Sep 2017 15:00:57 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A1328340806 for <gentoo-commits@lists.gentoo.org>; Wed, 6 Sep 2017 15:00:55 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3C6268E27 for <gentoo-commits@lists.gentoo.org>; Wed, 6 Sep 2017 15:00:54 +0000 (UTC) From: "Michał Górny" <mgorny@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" <mgorny@gentoo.org> Message-ID: <1504709957.a3c6899e26bb97644ba7aa919db794854172be5a.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/tests/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/tests/eapi7-ver:benchmark.sh X-VCS-Directories: eclass/tests/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: a3c6899e26bb97644ba7aa919db794854172be5a X-VCS-Branch: eapi7-ver Date: Wed, 6 Sep 2017 15:00:54 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: cecb8af7-c40d-4e40-bc46-0a5239ef1b69 X-Archives-Hash: 108174b021e7545fa362895a7a87fdd8 commit: a3c6899e26bb97644ba7aa919db794854172be5a Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Wed Sep 6 14:59:17 2017 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Wed Sep 6 14:59:17 2017 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a3c6899e eapi7-ver.eclass: Add some trivial benchmark eclass/tests/eapi7-ver:benchmark.sh | 73 +++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/eclass/tests/eapi7-ver:benchmark.sh b/eclass/tests/eapi7-ver:benchmark.sh new file mode 100755 index 00000000000..6a1001473b4 --- /dev/null +++ b/eclass/tests/eapi7-ver:benchmark.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +source tests-common.sh + +inherit eapi7-ver + +cutting() { + local x + for x in {1..1000}; do + version_cut 1-2 1.2.3 + version_cut 2- 1.2.3 + version_cut 1- 1.2.3 + version_cut 3-4 1.2.3b_alpha4 + version_cut 5 1.2.3b_alpha4 + version_cut 1-2 .1.2.3 + version_cut 0-2 .1.2.3 + version_cut 2-3 1.2.3. + version_cut 2- 1.2.3. + version_cut 2-4 1.2.3. + done >/dev/null +} + +replacing() { + local x + for x in {1..1000}; do + version_rs 2 - 1.2.3 + version_rs 2 . 1.2-3 + version_rs 3 . 1.2.3a + version_rs 2-3 - 1.2_alpha4 + version_rs 3 - 2 "" 1.2.3b_alpha4 + version_rs 3-5 _ 4-6 - a1b2c3d4e5 + version_rs 1 - .1.2.3 + version_rs 0 - .1.2.3 + version_rs 3 . 1.2.3 + done >/dev/null +} + +get_times() { + echo "${*}" + local real=() + local user=() + + for x in {1..5}; do + while read tt tv; do + case ${tt} in + real) real+=( ${tv} );; + user) user+=( ${tv} );; + esac + done < <( ( time -p "${@}" ) 2>&1 ) + done + + [[ ${#real[@]} == 5 ]] || die "Did not get 5 real times" + [[ ${#user[@]} == 5 ]] || die "Did not get 5 user times" + + local sum + for v in real user; do + vr="${v}[*]" + sum=$(dc -e "${!vr} + + + + 3 k 5 / p") + + vr="${v}[@]" + printf '%s %4.2f %4.2f %4.2f %4.2f %4.2f %4.2f\n' \ + "${v}" "${!vr}" "${sum}" + done +} + +export LC_ALL=C + +get_times cutting +get_times replacing