Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.misc |
| Subject | Re: how much computers can do in one second |
| Date | 2017-03-29 01:55 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <87vaqsvr4i.fsf@bsb.me.uk> (permalink) |
| References | <8737dzq71j.fsf@therandymon.com> <87r31iudou.fsf@elektro.pacujo.net> |
Marko Rauhamaa <marko@pacujo.net> writes:
<snip>
> Somewhat related. Here's a similar program to measure how fast the CPU's
> 32-bit integers wrap around:
>
>
> ========================================================================
> #include <stdlib.h>
>
> int main(int argc, char **argv)
> {
> int i;
> for (i = 0; i < i + 1; i++)
> ;
> return 0;
> }
> ========================================================================
(You can write this as
int main(void)
{
for (int i = 0; i < i + 1; i++)
;
}
in modern C.)
<snip>
> BTW, is your 2-gigahertz processor executing two instructions per cycle?
Modern machines don't work as simply as that (as I'm sure you know).
The above compiles to an inner loop of 5 instructions and takes (on my
machine) 4.34s for 2^31 iterations. That's a bit more than 2.4
instructions per ns. If I simplify the loop to
for (int i = 0; i >= 0; i++);
it compiles to 3 instructions but takes almost the same time (4.32s).
The lack of optimisation means that i is not in a register so cache
accesses are probably a limiting factor.
--
Ben.
Back to comp.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how much computers can do in one second RS Wood <rsw@therandymon.com> - 2017-03-27 14:43 +0300
Re: how much computers can do in one second Marko Rauhamaa <marko@pacujo.net> - 2017-03-27 15:06 +0300
Re: how much computers can do in one second Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-29 01:55 +0100
Re: how much computers can do in one second Marko Rauhamaa <marko@pacujo.net> - 2017-03-29 10:25 +0300
Re: how much computers can do in one second Richard Kettlewell <invalid@invalid.invalid> - 2017-03-29 08:52 +0100
Re: how much computers can do in one second Marko Rauhamaa <marko@pacujo.net> - 2017-03-29 12:43 +0300
Re: how much computers can do in one second Caecilius <nospam@spamless.invalid> - 2017-03-30 16:07 +0100
Re: how much computers can do in one second Marko Rauhamaa <marko@pacujo.net> - 2017-03-30 19:09 +0300
Re: how much computers can do in one second Bob Eager <news0006@eager.cx> - 2017-03-30 21:36 +0000
Re: how much computers can do in one second Marko Rauhamaa <marko@pacujo.net> - 2017-03-31 09:56 +0300
Re: how much computers can do in one second Huge <Huge@nowhere.much.invalid> - 2017-03-27 13:51 +0000
Re: how much computers can do in one second Sylvia Else <sylvia@not.at.this.address> - 2017-03-28 11:57 +1100
Re: how much computers can do in one second Huge <Huge@nowhere.much.invalid> - 2017-03-28 09:51 +0000
Re: how much computers can do in one second Bob Eager <news0006@eager.cx> - 2017-03-28 11:12 +0000
csiph-web