1. Eu time() in C?

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

new topic     » topic index » view message » categorize

2. Re: Eu time() in C?

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

new topic     » goto parent     » topic index » view message » categorize

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

new topic     » goto parent     » topic index » view message » categorize

4. Re: Eu time() in C?

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.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Eu time() in C?

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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu