This is a course page of David Casperson |
|
Click to return to the rest of the cpsc 200 information.
This page contains information about assignment one, which is due at the beginning of class 2007-09-27.
The original assignment handed out in class had several minor typos, and one medium-sized one. The corrected assignment can be found below. There should not be any meaningful difference between the original and revised assignments, except that the revised assignment is due this year, rather than last year.
It is tricky to get your stopwatch to give you more than milli-second precision. Below are some hints on how to do so.
It is tricky to get a good stopwatch function, and the details depend very much on the operating system. On galaxy.unbc.ca the following trick is necessary.
This assumes that you have written a StopWatch that uses gethrvtime function to get times.
When running your program to obtain a running time, run it
using ptime. That is, do something
like
ptime ./my_program > output.txt
Inside your program use your stopwatch as you normally would, and
print out times the way that you normally would.
The ptime command is necessary in order to
turn on the micro-timers to get accurate times.
I don't know how to do high resolution timing on Microsoft platforms. The article linked here seems like it might have code that works, but I don't have a way to test it, or to see what problems it might have.
It does seem like the code given lacks some of the features that I am asking for in my assignment.
On Mac OS X there is no gethrvtime function, but there is a getrusage function that returns fills a struct with information about the current resource usage of the program. In that resource usage is a struct timeval ru_utime field that keeps track of the elapsed user time.
fall-2024