help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: run time of math problem
Date: Fri, 19 Mar 2021 19:40:19 -0700	[thread overview]
Message-ID: <499ede49-ed95-005e-90d0-6c3265f4cea4@eastlink.ca> (raw)
In-Reply-To: <41359-1616197959.973399@0dqq.OWmi.jXTb>

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 
  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.

  reply	other threads:[~2021-03-20  2:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-19 23:18 Ray Andrews
2021-03-19 23:46 ` Lawrence Velázquez
2021-03-19 23:51   ` Ray Andrews
2021-03-19 23:52 ` Oliver Kiddle
2021-03-20  2:40   ` Ray Andrews [this message]
2021-03-20  3:59     ` Lawrence Velázquez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=499ede49-ed95-005e-90d0-6c3265f4cea4@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).