From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11650 invoked by alias); 4 Feb 2017 15:12:22 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 22434 Received: (qmail 25139 invoked from network); 4 Feb 2017 15:12:22 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-5.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(80.0.253.69):SA:0(-1.1/5.0):. Processed in 2.67331 secs); 04 Feb 2017 15:12:22 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _smtprelay.virginmedia.com designates 80.0.253.69 as permitted sender) X-Originating-IP: [86.21.219.59] X-Spam: 0 X-Authority: v=2.1 cv=CMjXJkfD c=1 sm=1 tr=0 a=utowdAHh8RITBM/6U1BPxA==:117 a=utowdAHh8RITBM/6U1BPxA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=MWUjAzoEKyAA:10 a=hl6XvUtGlO4fZBHb1NcA:9 a=CjuIK1q_8ugA:10 Date: Sat, 4 Feb 2017 15:05:13 +0000 From: Peter Stephenson To: Ray Andrews , Zsh Users Subject: Re: efficiency Message-ID: <20170204150513.4087c834@ntlworld.com> In-Reply-To: References: X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 03 Feb 2017 18:55:53 -0800 Ray Andrews wrote: > echo "\nSTOP TIMER. REAL RUNTIME: $((now-start)) MILISECONDS > ($(((now-start)/60000)):${(l:2::0:)$(((now-start)/1000%60))}) $@" > > integer -x base=$(((now-start)/1000)) > echo "\nSTOP TIMER. REAL RUNTIME: $((now-start)) MILISECONDS > ($(($base/60)):${(l:2::0:)$(($base%60))}) $@" > > ... is there any real advantage to the second line? Obviously I'm > trying to cut down on duplicate calculation, and in the real world it > hardly matters, but as a point of principal, which is better? The point of principle here is "don't repeat yourself"; it's better to do every calculation just once. Probably the main reason for this is what happens if you decide you need to change the calculation. (For example, you might decide to round the calculation differently. I'm clearly not suggesting you need to!) Then you only need to change one place. Getting used to that does help you avoid pitfalls in less trivial cases... pws