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,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13783 invoked from network); 23 Jan 2023 18:49:58 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Jan 2023 18:49:58 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1674499798; b=fSccGVCaXSmMFohc2k8SHHt/KMI1VR6SVVf0ZKqblbtQv3eBUvxgMNJlfMBunNsqluNOtIDlys bU5WmkA6jJAEizvSN+pTECRsi26bTmFF1nK5yjkGcAyQ3mANH/tP4LY3UitXFxVfO4FHLeXNv4 /s6qs9Vqoztw9fsRpfSdXi7cFtpEi23oDvH3LLW9hWXTjqhcx1uiaIBraMoXmElhAYr+wkyNri t3gkBuQrWAEtVz5FnsXinlfXWnjFpuHx886pd9+P/ZTQlKz68HW6h/stw1skNv3jlxKwROO4Ob R+2sSjwOpL+21T6tw4MD0gKDVJzt/N2HKMI07N5MNlIbmw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mout.gmx.net) smtp.remote-ip=212.227.17.21; dkim=pass header.d=gmx.de header.s=s31663417 header.a=rsa-sha256; dmarc=pass header.from=gmx.de; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1674499798; bh=ibEbNK+RHd0B6xhSL+vMKjy8fdLSefcpoio6ta7nbIA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:In-Reply-To:Content-Type: MIME-Version:References:Reply-To:Message-ID:Subject:To:From:Date: DKIM-Signature:DKIM-Signature; b=JmULG/O4mqJ+cC8sYPvz/zwDcdPghGF041AtG477ugwaMHdUg6aopHqpDK21QhAaXwhZc5ZyKN Y+UwVfKYFnx2YzrWAQTImO2kQw9D4Vr3EuDSeP0i/Zbu1A4b1BMjLFUi+vBmtfJqbjVLiKPPcP TeOMUVm0Yvh0BzjoUPl07wRoflX2q5DTgZ5xsUbg0rwSuFCJaWYQ0JCurXWMGcApeVQowGDyHw OuRt0CUGuAexzQDwuJeOuraQm/hjCXJ0gSSEmCsJ7H7IIKh4juEzJjEYEvAZd4ewp4DhpylSo4 WZE5T5wxgSKnziVwXBp9EQ26/JGdIKinv9LSElBTcoRAAQ==; 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:Content-Transfer-Encoding:In-Reply-To :Content-Type:MIME-Version:References:Reply-To:Message-ID:Subject:To:From: Date:Cc:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=ZzKN41sd/J2UZD5+8QotFpr/qGDRPxaX2B+eAY+IcmI=; b=FXAriTvdevQE/ed5PhxJH0LOEy U7h4nnXOSbFIrRdcx+J8Cm6kU1JBcqkfkWkJ8DR509CoIEO+AVE5Bd4ot90I6zYTapll2AK4WwoF5 +5sUkdpSvVOyh+AarAodeMfGe+T9qJFS2X4UjbJzdUVIaBzkG2JR7PAvTqPXaXwG+22CJItcBfPHH jMREnjRRsQvlfAojT84A+1qpTgJ1tMf1t8/IrEP0J1z32UFVitdPiqcJ4V4W20z6eZWL+PCnRWyhe ez40FVkVHp3SEEXMoC91IaUeaZd3vWMlbUsCuBieN/uFlY514uopo+M5RQXaEJPOcNc/HglubOmi4 19ejr4FA==; Received: by zero.zsh.org with local id 1pK1tF-000Lei-PS; Mon, 23 Jan 2023 18:49:57 +0000 Authentication-Results: zsh.org; iprev=pass (mout.gmx.net) smtp.remote-ip=212.227.17.21; dkim=pass header.d=gmx.de header.s=s31663417 header.a=rsa-sha256; dmarc=pass header.from=gmx.de; arc=none Received: from mout.gmx.net ([212.227.17.21]:33511) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1pK1sl-000Kwt-LS; Mon, 23 Jan 2023 18:49:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1674499766; bh=ibEbNK+RHd0B6xhSL+vMKjy8fdLSefcpoio6ta7nbIA=; h=X-UI-Sender-Class:Date:From:To:Subject:Reply-To:References: In-Reply-To; b=iJar89KkL5L/7kc2wDXZL+HSpv9azuPPOjpVgXn9PwXIDBoZflESXaP39mNYURzL6 E5LehWJ3Cz2d4zM1lbKDfRbhE4QCqTrUem1jDHCilslUdrUB+AO7IlBlMeTg2AxguD y+mrWx1Ac7uFx8WF089dNFPjpsjxntYpSvqQAHhx1Ayj611OnLyg3N8XUt5Be+ASA8 /5f5hQFyufuZ/u5Wtz/MpZpCu5cgNdTkiXNw/Yps8Dn7DyCFJoDuyU/M6i9fIScJXr 4N5wvsYDTTg2QTm2xyfpYPBx3J5qIgtK+0CyvXleenmTie0thiKQb1JdFiWWlXZoZl bwAaP3G/mAgFg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from limone.obstwiese ([46.223.163.213]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MnJhU-1osQHy3V12-00jGcu for ; Mon, 23 Jan 2023 19:49:26 +0100 Received: from luthien by limone.obstwiese with local (Exim 4.94.2) (envelope-from ) id 1pK1sh-0004z4-Re; Mon, 23 Jan 2023 19:49:23 +0100 Date: Mon, 23 Jan 2023 19:49:23 +0100 From: Dominik Vogt To: Zsh Users Subject: Re: time command with shell builtins Message-ID: Reply-To: dominik.vogt@gmx.de Mail-Followup-To: Zsh Users References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Provags-ID: V03:K1:TGttH1gHbmvzZ/GcVMH9ug/GIcMucfV/175Vh5OfNkRjQwRmT2S TTYtqILApZjJBAhlVz6oCdhCAT1CS0nVNlNEqWtReAJOsfXA3x23JtguzArs3coNEe/dSAr YJUEJDlLw2JrmcaOvgPJL4hUSo8gJoWOjCaPWBC8t0e4RDPEh0o5DhfpnEdIYL0sBCT0X0n GhyFkyIK3Tu0BiMsmavyQ== UI-OutboundReport: notjunk:1;M01:P0:Rg1hy9npVzs=;fJbDBy/uR9HkqbOAPnji8L5Jc31 tWTCt3oM3jFMcn8x1ak6jmj5ryVBYCz9wweYoWfucbcefpeugbRoDKJBv4V5VjfEoW1ZLCHM0 0bkiglBOgpbTrVeHcPVko6el8Z5C8Qx8o4Bg5KK7+wKXJwACoumI2av5EUIzmXcSNKZhQAGqx PAQbK5y1p2OiDrYgCHZCgMHbP2FLb7WNMiE+3c0zrcd5tEkqy6IlCSrGicJm3Kwoi5XxlMC9N b2MrKWziJRdh8yDu+w4Foeec8DLbob+xhJO2Jrc5BbsOCFbKcYx2bJNbKu6Zlt+lMwSvvMPfp d3i66BhCl1xlKebArTAliEES7qax8ibej4Qeu/wxwef2emkcqjB1JJdDyK8WG+5RmSxxOeGYb J5x+hgUKSmK+Zs5dtWceBEG6gRm36qB9zzPLOOrfOEW1v7cJzDUGTeR6GVIzhZOt9gcWayGOf HnJjX5yBzLpVik+HB+mIqg5Ix1xlVJ/FeBkFNyc+wFWAMYL4erxIDjowtn7LyYCYPg+2de6ga PpYHT3Gqbh7KXgQJGcxRAXRp39ubntRqnAq4jYMvbKw/nLxzM5grVxUGaV0HB9B6szjKwfcWq kQcwXhHuBEeUD7OZilHXUGOoSS4CFygSrm99LvtZli/Z2uZOvfiZlm8NfEsQnoCgVV5rsWcCg sbR+pHrrbTwOevrdu7OBjDpgKNHr1F0fdSzKITLKvUCGdXe/3vL7CqTAxj3rE+6Rves6TmenU 3u617P9EJ8ZYMxJIJ//abmDdtILj1olI4WpBbEeUk94Z5ofvGTz1OO+IjJP1bOD97Gi7Iw2H1 sck1plpYdwpmZ4eTm4ZVj08Kj3MIzdcOo8y7gn41nMI8jE5U1ykntKk47gvaNq8qoFmoAmMsi 64pkCowQeCLvU6k9DsPFLIQAapJtGQSm/R6ngTSCYtCIigjNfjOZ4QD5KDsuwXwpGi6/r/ASh 4y0qJfCjWh+U34ISVr0uvj+8kIM= Content-Transfer-Encoding: quoted-printable X-Seq: 28757 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, Jan 23, 2023 at 07:31:12PM +0100, Mikael Magnusson wrote: > On 1/23/23, Dominik Vogt wrote: > > On Mon, Jan 23, 2023 at 02:42:05PM +0100, Roman Perepelitsa wrote: > >> On Mon, Jan 23, 2023 at 2:40 PM Dominik Vogt wr= ote: > >> > > >> > 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 ) > > > > That wasn't really the question. Of course I can time a loop by > > writing a different command, or by putting it in a pipe or file. > > > > $ time echo foo | true > > > > I just want to get timing statistics of loops either explicitly by > > prepending "time" or implicitly with REPORTTIME. > > As Bart already mentioned, the answer to your question is "no", but > you can avoid some downsides of the subshell (eg, if your loop has > side effects that are relevant to the rest of the script etc), by > using SECONDS: > % () { typeset -F4 SECONDS=3D0; sleep 1; () { typeset -F3 SECONDS=3D0; > sleep 0.43; echo $SECONDS }; sleep 1; echo $SECONDS } > 0.431 > 2.4329 > (the downside here is obviously that it doesn't split out cpu/system > time for you, only elapsed time). Well, the worst downside for me is that REPORTTIME does not work. The use case is "oh, that command ran a long time, I'd really like to know how long it took". I see no solution for that if re-running the command is no optiuon because it takes too long. At the moment I'm writing some automation scripts that run for hours and print their progress. I might want to kill them after a few hours and see how many seconds they ran and compare it to the progress output. Ciao Dominik ^_^ ^_^ =2D- Dominik Vogt