1. Eu time() in C?
- Posted by Martin Stachon <martin.stachon at worldonline.cz> Sep 25, 2002
- 498 views
Hi, I am rewritting some Euphoria programs to C to see how much the speed differs. In Euphoria, I measure the timings with time(), but how can get exact same timings in C? (I probably need some reference for standard libraries, figuring it out from header files is not always ok.) I have some forms, which one is correct? (I have Borland 5.5) #include <time.h> unsigned long int time_(void) /* which one is Euphoria time() ? */ { return clock()/CLOCKS_PER_SEC; }; /* or */ { time_t *timer; /* for what? */ return time(&timer); }; /* this one crashes */ { struct tm *tblock; tblock = asctime(&tblock); return tblock->tm_sec; }; Regards, Martin Stachon martin.stachon at tiscali.cz http://www.webpark.cz/stachon
2. Re: Eu time() in C?
- Posted by Robert Craig <rds at RapidEuphoria.com> Sep 25, 2002
- 495 views
Martin Stachon writes: > unsigned long int time_(void) > /* which one is Euphoria time() ? */ > > { > return clock()/CLOCKS_PER_SEC; > }; Try instead: > double time_(void) > { > return clock()/(double)CLOCKS_PER_SEC; > }; That will give you a floating-point result. Your routine will give a result rounded down to an integer number of seconds. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
3. Re: Eu time() in C?
- Posted by kbochert at copper.net Sep 25, 2002
- 511 views
On Tue, 24 Sep 2002 17:32:46 +0200, Martin Stachon wrote: > >Hi, >I am rewritting some Euphoria programs to C to see how >much the speed differs. >martin.stachon at tiscali.cz >http://www.webpark.cz/stachon > Have you seen ? http://dada.perl.it/shootout/ Karl Bochert
4. Re: Eu time() in C?
- Posted by Martin Stachon <martin.stachon at worldonline.cz> Sep 26, 2002
- 486 views
Thanks, Rob. I am still confused with the C types... Martin > Try instead: > > > double time_(void) > > { > > return clock()/(double)CLOCKS_PER_SEC; > > }; > > That will give you a floating-point result. > Your routine will give a result rounded down > to an integer number of seconds.
5. Re: Eu time() in C?
- Posted by Martin Stachon <martin.stachon at worldonline.cz> Sep 26, 2002
- 497 views
Would be nice to see Euphoria here... Martin ----- Original Message ----- From: <kbochert at copper.net> To: "EUforum" <EUforum at topica.com> Subject: Re: Eu time() in C? On Tue, 24 Sep 2002 17:32:46 +0200, Martin Stachon wrote: > >Hi, >I am rewritting some Euphoria programs to C to see how >much the speed differs. >martin.stachon at tiscali.cz >http://www.webpark.cz/stachon > Have you seen ? http://dada.perl.it/shootout/ Karl Bochert