🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #7028

Re: timer

#7028
From: Steve Yelvington
Date: Mon, 15 Jan 1990 16:56
60 lines
2452 bytes
[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.  

The Random() xbios function executes too fast to be timed even with a
clock that ticks 200 times a second. You could call it 1000 times and then
compute the average, but you'd also be timing the loop that called
Random().

The 200-Hz system timer is in protected memory and accessible only in
supervisor mode. The dLibs C library (the one that comes with the Sozobon
compiler) has functions that make this easy. The program below
demonstrates these functions (with an example that takes a few
milliseconds to complete). If your compiler doesn't have start_timer() and
time_since(), you can find the sources in the dLibs timer.c file.

To compile this with Sozobon, cc it with the -f flag (floating point).

Incidentally, I got these results:

0.075000 with no scrolling (starting with a clear screen).
0.175000 if the program had to scroll the display.
0.445000 when I redirected it to a file.

    0/ cut here
=== 0\============================================================

#include <time.h>
#include <osbind.h>

main()
	{
	clock_t t;
	float tt;

	/* record the starting time */
	start_timer(&t);	

	/* do something that takes some time */
	printf("Ob lah dee, ob lah dah\n");
	printf("life goes on, brah!\n");
	printf("La, la, la, la life goes on....\n");

	/* get the result */
	tt = (float) time_since(&t);

	/* print a report */
	printf("\n\nOb lah dee took %f second(s).\n", tt / CLK_TCK);
	}

    0/ cut here
=== 0\============================================================

-- 
   Steve Yelvington at the (all-too-warm and windy) lake in Minnesota
   UUCP path: ... umn-cs.cs.umn.edu!thelake!steve
Technical Details
Message-ID: <0015901056020561@thelake.mn.org>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mailrus!cs.utexas.edu!uwm.edu!uwvax!umn-d-ub!umn-cs!thelake!steve
References: <6667@wpi.wpi.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mailrus!cs.utexas.edu!uwm.edu!uwvax!umn-d-ub!umn-cs!thelake!steve
From: steve@thelake.mn.org (Steve Yelvington)
Newsgroups: comp.sys.atari.st
Subject: Re: timer
Message-ID: <0015901056020561@thelake.mn.org>
Date: 15 Jan 90 16:56:02 GMT
References: <6667@wpi.wpi.edu>
Organization: Otter Lake Leisure Society (White Bear, Minnesota, USA)
Lines: 60
X-Member-Of: STdNet, the ST Developers' Network