From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 17906 invoked from network); 23 Jan 2023 14:47:57 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Jan 2023 14:47:57 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1674485277; b=kgMgAMLFjOtr04MP2zizm9HwnfNUrfdm6i0BgSM21Txmjn5c19nwwGZYVNS7px4qMd5Y/+UYjH nbHUAP3E4+Y0+YYDfEnTlalzgkfS+HsrNXEo++v5oLWw+egmvs9LS1IJFGi6ZB0OP0BMI4ceLH heyh84CLFLVb37Xq9n9U9HyNUGlNv5Cy8f5TmLOJQ4Dv3I3MUblzg1XOPTrHdK/wBAFQZ3VCIg Hsb0zxWbmVBnK8FlUkON4P9gboyNy6fN2ZwPo955dfnd2CjurWGJviZtZFgaZb+++2V/ozZmnn IF9u0GGgP1OrxwCyC6ot1ob32Gb+f7nf3vi9XTgC7iKWVg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mailb2.tigertech.net) smtp.remote-ip=208.80.4.154; dkim=pass header.d=blaatscaahp.org header.s=2.tigertech header.a=rsa-sha256; dmarc=pass header.from=blaatscaahp.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1674485277; bh=OAME5LttRnU43L9P7PvKRzLbZGmXn9mB4og4xfScrKg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:References:In-Reply-To:Subject:Cc:To:From:Date:Message-ID: DKIM-Signature:DKIM-Signature; b=qoUeqQdyvWYZ31i9hiFWcYohJRRiNDSrGUsa4MwjMdFkhNEaHvh+/8Je+fT5k+KWai0+b6TF5x ungKBoNrrNeR0Pfe+EnMY4SAmWiWAMZxCPjir91i/Xb8/mU3Rx7k+CRrmg8t9T//iLn/l0ki+H BKoB6je0S1fp++WusR46pLTgU6jFmfVbUhPzaCo0Glen50vII3IWI8N+KcL/DHjKQ14u9uZO3b eN412lDWVEPG/Xhm2JZl9IKWrUXEKQNyDERx8Gkzr4oGtv2rYjfxxQEo8NdADDCFm01NWHTM9g ooXTwkJ4I65SrfxmI9wCenDYE9JZNOepxYY/F9R8lxPt/w==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:References:In-Reply-To:Subject:Cc:To: From:Date:Message-ID:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=NhttyRFbCsX3uVhyP2CLkQQNaVZCGnaa5FXRLyou/Kk=; b=m9mdgRZZtRywNfBNxPkO3G/01p F0Z566ENjvJabacLPKfX4xmW9+Bm0o7sjzjJQyvQ7cpoQwumACnFXyPijwcWdQuZmJB4+bEBWrKSk KjPfsOQG/Wn910cf9C5ufc/o8z6xXbJ9oS1Mjq6B7RqjSmMxVnnB8XzRMco4OrA6tneQ4nNQt3BYg Pk871+7TKutrawflt0xpOa1ElLsBfC1OvCaJvF4DOqhWfDmD5J3n6UuIcVhV0bDT3UUBNDwxecdYf bMxUNsPUwQlYRPktMKZWYYM4QWXwIh2LiUlFWfSkLitfm8Y+MhKEF14EZxPTtVtZkoNnWbisl8Aou h24FRl/w==; Received: by zero.zsh.org with local id 1pJy73-0001Ax-4e; Mon, 23 Jan 2023 14:47:57 +0000 Authentication-Results: zsh.org; iprev=pass (mailb2.tigertech.net) smtp.remote-ip=208.80.4.154; dkim=pass header.d=blaatscaahp.org header.s=2.tigertech header.a=rsa-sha256; dmarc=pass header.from=blaatscaahp.org; arc=none Received: from mailb2.tigertech.net ([208.80.4.154]:32947) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1pJy4P-0000Nc-Fl; Mon, 23 Jan 2023 14:45:14 +0000 Received: from localhost (localhost [127.0.0.1]) by mailb2.tigertech.net (Postfix) with ESMTP id 4P0tDk2mLGz1pZ89 for ; Mon, 23 Jan 2023 06:45:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blaatscaahp.org; s=2.tigertech; t=1674485110; bh=NhttyRFbCsX3uVhyP2CLkQQNaVZCGnaa5FXRLyou/Kk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=YTyTnpUAfGsOS1Ug2Qpb4+AODSgOYMgkEjRYrejnNwtAYkR4rCrV2wvWMTRcxMw+/ zyzBUq8vQ1nCNhhEeQJPTFTqDgv8d4icRHgehmIH4Pxi+7ZPtCHIsAqjSq44dh838H 0KNt4ru1LkcTmyQj0Chhgu1vHD49dNs4KAIROtlU= X-Quarantine-ID: X-Virus-Scanned: Debian amavisd-new at b2.tigertech.net Received: from localhost (cst-prg-89-91.cust.vodafone.cz [46.135.89.91]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailb2.tigertech.net (Postfix) with ESMTPSA id 4P0tDj2YbBz1pM8h for ; Mon, 23 Jan 2023 06:45:07 -0800 (PST) Received: by thinkcrap.localdomain (Postfix, from userid 1001) id B9F3135546A; Mon, 23 Jan 2023 14:45:04 +0000 (UTC) Message-ID: Date: Mon, 23 Jan 2023 14:40:16 +0000 (UTC) From: zeurkous@blaatscaahp.org To: Roman Perepelitsa Cc: dominik.vogt@gmx.de, Zsh Users Subject: RE: Re: Re: time command with shell builtins In-Reply-To: References: User-Agent: 822_dng. X-Seq: 28745 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Mon, 23 Jan 2023 15:23:57 +0100, Roman Perepelitsa wrote: > On Mon, Jan 23, 2023 at 3:20 PM wrote: >> >> On Mon, 23 Jan 2023 14:42:05 +0100, Roman Perepelitsa wrote: >> > On Mon, Jan 23, 2023 at 2:40 PM Dominik Vogt wrote: >> >> >> >> Is it possible to get timing statistics of shell builtins too? >> >> Timing "echo" isn't very interesting, but timing loop constructs >> >> would be: >> >> >> >> $ time while foo; do bar done >> > >> > This: >> > >> > % time ( while foo; do bar; done ) >> >> Doesn't that imply a fork, which will also be timed...? > > Yes, it does. > >> (Could lead to misleading results, in that case.) > > Any tool that measures how long a piece of code takes to run gives you > an upper bound, so there is nothing new here. A fork(2) can be particularly expensive, though, so there's an opportunity to make things better here. > The standard solution is > to ensure that the code under benchmark takes a non-trivial amount of > time to execute. Here's the standard pattern I use: > > time ( repeat 1000 code-under-benchmark ) > > I tune the loop constant so that the benchmark takes around a second. Me's of course aware of such workarounds (they aren't solutions, though me agrees that a complete solution would be far beyond our scope). --zeurkous. > Roman. -- Friggin' Machines!