From: pawley@tnc.airtouch.com (Sam Pawley)
Subject: Re: Help in measuring time
Date: 1995/06/21 [thread overview]
Message-ID: <DAJFzA.9C1@nit.airtouch.com> (raw)
In-Reply-To: 3s88s2$80b@hermes.acs.unt.edu
sarkar@ponder.csci.unt.edu (Falguni Sarkar) writes:
>I am using a DEC Alpha machine. When I try to compile the
>following code I am facing problems.
>#include <stdio.h>
>#include <time.h>
>time_t tim1,*tp;
>main(){
> tim1=time(tp);
> if(tp==NULL)
> printf("tp is NULL\n");
>}
It should read...
(appropriate #includes)
main()
{
time_t tim1, tim2;
time(&tim1);
/* do the stuff to be timed */
time(&tim2);
printf("Took %d seconds to run\n", tim2 - tim1);
}
The parameter passed to time() needs to be the address of some storage.
Just declaring it as "time_t *tp;" does not alocate any storage, it just
declares tp to be a pointer to a time_t (an unsigned long int). Time() is
pretty low resolution. It only returns whole seconds. You might want to
try some of the higher resolution methods that Ive seen posted here.
EMail me for copies if you need them.
Hope this helps!
-=[ SamBones ]=-
-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Hungry man, reach for the | This | pawley@tnc.airtouch.com
book: it is a weapon!" | space for | sam.pawley@atlas.ccmail.airtouch.com
Bertold Brecht | Rent | (714) 798-2050
-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
prev parent reply other threads:[~1995-06-21 4:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-06-21 4:00 Help in measuring time Falguni Sarkar
1995-06-21 4:00 ` Sam Pawley [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox