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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 29026 invoked from network); 20 Mar 2021 02:41:01 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 20 Mar 2021 02:41:01 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1616208061; b=bY+LU7PCykL5kEE0pVJCgIKKjP3Ak2+o/Un+s2W04jfgsprvNxKjQWR2DshjrPMiNZu/WcjnwR 8wRQLtm9bXXQsPhhvdOWH1USm79jNSn8zxVUewJTMMcOT+aEeJd+/SnalXqYFUsrzsXCEGyH6J PMlYgLNs3Mo6JD/mBu/OErDVFfif4a/3c7hc/Q4avMkvXie7N/frFIRJ1cmjzJILroHPgtwecu Z1W2TSDcR3tA1UBuNrt8PslVuaSgBW+vO8TGn50JqwKapyFBSmeLtD4x8Hr85ii01EQzPruXFc byB0bGUvLWqYG1aErjndmdU5Cc5IEHyOqAZjGw0VGMRHdQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta04.eastlink.ca) smtp.remote-ip=24.224.136.10; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1616208061; bh=h/klU38gf3ybaHgVsTVyBQ/owkgRDsHObeRqFBY8YUw=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:To:Subject:DKIM-Signature; b=fY1dU8+2Zz/4E0w0VEWErbAhUjxiOWw6y6VmlZTCdmVCX6mOXTQrYxMFhPrJn37V4e5hYvJoVH y3dcQRbkN/gPpzyjRN1fhmuaDfieQGD9qlzW8bFC+7Z5bSNVhNiKdJ/bxFXCFigmmB1arbcpt7 jOEMs/dJA1Zt2GK/8GiqCaO6y/Qk0wypHVPnD9jcGOo+eFdY3JrdyR2LbfSpKVn3pAOJ2xykzC asamqcz96xiJ7+BPdXKN2T8ZOFNw0/WC+UsKoA4BoNuLpPaSRbFOFvUHZfPFE37MpyywRCxu1r 0BRn5Fsz1jsJo3BB9wwe8aYk6XqnMKphKSP+sbNGE5qxTg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-transfer-encoding: Content-type:In-reply-to:MIME-version:Date:Message-id:From:References:To: Subject:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=gpieS9FqkrSNZwkD/B1BKgD26kzG3vJELqn+oACrMSg=; b=sKKo+iA16AapKfTykRLHaZy+OD H09HAA4/ELu5nt6ydc5vs4P3s83u1ifsTgLtgD+oZvzevEXdXqIJY0AzMjrPL/UdG2iynR/AxWCLU UozCLRvtle2PO/xxuj7oLE5AG/ggn5seWMgVHY3ZUDMuiNm/w7SCAYcEuUxiCTwvfNKGBG4na7wS7 z8NMkX5fE4d+ObZWaysqBUVBayqefpGnnvGaCBf5F2C+kc9+tETDP26Jq7s+pM5eRBHnhbZO0k52+ jcj27z+WaMFJY1kyRDFR7JQi4u27GiTVK5oHy4rccPVQtLGKo4ULwnnX65r8RrOihsv/PXe3wYb54 UN5KmK9A==; Received: from authenticated user by zero.zsh.org with local id 1lNRXu-000LXJ-T5; Sat, 20 Mar 2021 02:40:59 +0000 Authentication-Results: zsh.org; iprev=pass (mta04.eastlink.ca) smtp.remote-ip=24.224.136.10; dmarc=none header.from=eastlink.ca; arc=none Received: from mta04.eastlink.ca ([24.224.136.10]:37519) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1lNRXK-000L9z-Ed; Sat, 20 Mar 2021 02:40:23 +0000 Received: from csp02.eastlink.ca ([71.7.199.167]) by mta04.eastlink.ca (Oracle Communications Messaging Server 8.0.2.2.20180531 64bit (built May 31 2018)) with ESMTPS id <0QQ8009U0XVB3731@mta04.eastlink.ca> for zsh-users@zsh.org; Fri, 19 Mar 2021 23:40:20 -0300 (ADT) Received: from [192.168.0.2] ([24.207.90.194]) by Eastlink with ESMTP id NRXIlzn1Q54V7NRXIlIoTR; Fri, 19 Mar 2021 23:40:20 -0300 X-Authority-Analysis: v=2.4 cv=PJ/KRdmC c=1 sm=1 tr=0 ts=60556094 a=zv49KfEsxEDzuN5AGO7r0Q==:117 a=zv49KfEsxEDzuN5AGO7r0Q==:17 a=IkcTkHD0fZMA:10 a=ynty0-LWAFV7qEV1t_YA:9 a=QEXdDO2ut3YA:10 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudefledgjeelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptfgrhicutehnughrvgifshcuoehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgeqnecuggftrfgrthhtvghrnhepkedvueeuffefhfdvueeiteffvddtvdejgeeujeekieduheeiteeiheegtedvhfefnecukfhppedvgedrvddtjedrledtrdduleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrdeltddrudelgedphhgvlhhopegludelvddrudeikedrtddrvdgnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrghdpghgvthdqkghiphfrrghsshifugepthhruhgv X-Vade-Score: 0 X-Vade-State: 0 X-EL-IP-NOAUTH: 24.207.90.194 Subject: Re: run time of math problem To: zsh-users@zsh.org References: <41359-1616197959.973399@0dqq.OWmi.jXTb> From: Ray Andrews Message-id: <499ede49-ed95-005e-90d0-6c3265f4cea4@eastlink.ca> Date: Fri, 19 Mar 2021 19:40:19 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-version: 1.0 In-reply-to: <41359-1616197959.973399@0dqq.OWmi.jXTb> Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 8bit Content-language: en-US X-Seq: 26587 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: Archived-At: On 2021-03-19 4:52 p.m., Oliver Kiddle wrote: > > If you want to optimise for speed, avoid string conversions and do, e.g. > (( divided = sum * (1.0 / level) )) Thanks, that's easy to miss but it makes sense.  One of those invisible things.  Doing it that way throughout is fully 3X faster.  Running it up to a billion itterrations it starts to matter. As to the rest I was just stupidly forgetting that I'm in a loop. I'm faking a summation. We don't have summation do we? > You also may want to make sure to declare some of the variables as float > or integer or whatever. The sum+= line might end up being a string > concatenation if not. Yeah, I left out the declarations but it was all kosher.