|
From: David M. <ci...@ya...> - 2003-08-06 10:06:54
|
I like dos. Anyway I don't use it for everyday tasks. Only
for doing some
long calculation that I don't want to give my main system.
Someone had asked wether it would be better to constantly
re-call a function
in a for loop or t copy the value to a varible and use that
instead.
The idea was to show the code running on an extremly slow
system (with
absolutely no bells and whistles) so a relatively decent
comparison could be
made. Besides, if I did not have this system I would have
to make getint()
return a much bigger number (most comps today go through
50,000,000 too fast
for time() to give a different time reading)
Who messed with my output? It is supposed to be:
Function call time taken = 40
Varible buffer time taken = 16
----- Original Message -----
From: "Scott Simontis SIMONTIS" <age...@co...>
To: <ci...@ya...>
Sent: Tuesday, August 05, 2003 7:57 PM
Subject: Re: [Dev-C++] loop optimization
That is way too slow to use. I use a laptop with a Pentium
MMX 180 MHz
CPU, 24MB RAM, 1.5GB HD, and dev-cpp for my old computer.
Consider
never using that again.
~~Scott Simontis~~
Programmer
----- Original Message -----
From: David McKen <ci...@ya...>
Date: Tuesday, August 5, 2003 7:44 pm
Subject: Re: [Dev-C++] loop optimization
> Ok here is a test I tried on a OLD comp I have lying
> around.
>
> System specifications:
> 25Mhz 486 (no math co-processor)
> 4Mb Ram
> Compiled using the Pacific C compiler (djgpp runs WAY too
> slow) using full
> optimization.
>
> Program:
> #include <stdio.h>
> #include <time.h>
>
> long getint(void);
>
> int main()
> {
> time_t begin,end;
> long i, get_int;
>
> begin =time(NULL);
> for(i =; i < getint(); ++i);
> end =time(NULL);
> printf("Function call time taken =i\n", end - begin);
>
> get_int =getint();
> begin = time(NULL);
> for(i =; i < get_int; ++i);
> end = time(NULL);
> printf("Varible buffer time taken =i\n", end - begin);
>
> return 0;
> }
>
> long getint(void)
> {
> return 50000000;
> }
>
> Output:
> Function call time taken =0
> Varible buffer time taken =6
>
> Hope this helps.
>
> ----- Original Message -----
> From: "OROSZI Balázs" <or...@vp...>
> To: <dev...@li...>
> Sent: Tuesday, August 05, 2003 3:17 PM
> Subject: Re: [Dev-C++] loop optimization
>
>
> > Graham Douglas wrote:
> > > Run the profiler to find out where the inefficiencies
> are. In my
> > > experience, any attempt to prejudge optimisation will
> be wrong. The
> > > inefficiencies are _never_ where you expect.
> > >
> > > The two fundamental rules for optimising by hand are:
> > >
> > > rule 1: don't do it.
> > > rule 2: don't do it - yet.
> >
> > Thanks. Advice taken :)
> >
> > --
> > Greetings,
> > Balázs
> >
> >
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
|