From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,b1405ae95ca8c2c2 X-Google-Attributes: gid1164f8,public From: pawley@tnc.airtouch.com (Sam Pawley) Subject: Re: Help in measuring time Date: 1995/06/21 Message-ID: #1/1 X-Deja-AN: 104873831 distribution: inet references: <3s88s2$80b@hermes.acs.unt.edu> organization: AirTouch Communications keywords: ALPHA,CC,GCC, time newsgroups: comp.sys.dec 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 >#include >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 -=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-