Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Newsgroups | comp.misc |
| Subject | Re: how much computers can do in one second |
| Date | 2017-03-27 15:06 +0300 |
| Organization | A noiseless patient Spider |
| Message-ID | <87r31iudou.fsf@elektro.pacujo.net> (permalink) |
| References | <8737dzq71j.fsf@therandymon.com> |
RS Wood <rsw@therandymon.com>:
> Interesting website: they provide sample code and you have to guess how
> many iterations a computer can complete in a second. Example:
>
> #include <stdlib.h>
>
> // Number to guess: How many iterations of
> // this loop can we go through in a second?
>
> int main(int argc, char **argv) {
> int NUMBER, i, s;
> NUMBER = atoi(argv[1]);
>
> for (s = i = 0; i < NUMBER; ++i) {
> s += 1;
> }
>
> return 0;
> }
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;
}
========================================================================
Without optimization:
$ cc -o test test.c
$ time ./test
real 0m4.880s
user 0m4.873s
sys 0m0.001s
With optimization:
$ cc -O3 -o test test.c
$ time ./test
[stuck forever...]
> The speed of light is about 300,000 km/s. That translates to roughly 1
> ns per foot (yeah, I mix up my units... I'm Canadian...)
>
> THUS, a computer with a clock speed of 2 GHz will be able to execute,
> on a single core/thread, about 4 (four !) single-clock instructions
> between the moment photons leave your screen, and the moment they
> arrive into your eye 2 feet (roughly) later.
>
> _That_ should give you an idea of how fast modern computers really
> are.
It's even more impressive when you consider the speed of sound: 340 m/s
(or 256,000 miles per fortnight for you Canadians).
Your computer will be able to execute over 4 million (!) single-clock
instructions between the moment the beep leaves your speaker and the
moment it arrives into your ear 2 feet later.
BTW, is your 2-gigahertz processor executing two instructions per cycle?
Marko
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