Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!sjsca4!greg From: greg@sj.ate.slb.com (Greg Wageman) Newsgroups: comp.sys.atari.st Subject: Re: timer Message-ID: <1990Jan16.013746.5148@sj.ate.slb.com> Date: 16 Jan 90 01:37:46 GMT References: <6667@wpi.wpi.edu> Reply-To: greg@sj.ate.slb.com (Greg Wageman) Distribution: usa Organization: Schlumberger ATE, San Jose, CA 95110 Lines: 23 Opinions expressed are the responsibility of the author. In article <6667@wpi.wpi.edu> jstorey@wpi.wpi.edu (John R Storey) writes: >I'm writing a C program and have a small problem - I want to time how long >a call to the Random ( ) XBIOS function. The problem is that I can't figure >out how to time it in increments smaller than 2 seconds. You don't say which compiler you're using, so this may not apply to you. Mark Williams C provides a function called "clock()", which returns the number of clock ticks since the system was booted. The constant CLK_TCK encodes the number of ticks/second. It so happens that the clock() functions uses the 200hz system timer, so if you save the value returned by clock() (an unsigned LONG) before and after the Random() call, and difference them, you will get the number of clock ticks elapsed, more or less. Integer division by CLK_TCK will give you elapsed time in seconds; modulo CLK_TCK gives you the remainder in 5-millisecond ticks. Copyright 1990 Greg Wageman DOMAIN: greg@sj.ate.slb.com Schlumberger Technologies UUCP: {uunet,decwrl,amdahl}!sjsca4!greg San Jose, CA 95110-1397 BIX: gwage CIS: 74016,352 GEnie: G.WAGEMAN Permission is granted for reproduction provided this notice is maintained.