Unix Programming - Is clock C function appropriate as clock counter?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > June 2004 > Is clock C function appropriate as clock counter?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Is clock C function appropriate as clock counter?
Leonardo Barbosa e Oliveira

2004-06-16, 5:57 pm



Hello, everybody!

I am using the C function clock() as a counter
of number of ticks of my programm. I am newbie in benchmarking
architectures so please let me know if i am the
right thing. I am using a Ultra-Sparc 5

thanks in advance!

The function is described here:

http://htmlhelp.sunsite.dk/page.php/9/ch22s03.html

Leonardo


=09"A gente s=F3 sabe bem aquilo que n=E3o entende".
=09=09=09=09 Guimar=E3es Rosa
Nick Landsberg

2004-06-16, 5:57 pm

Leonardo Barbosa e Oliveira wrote:
>=20
> Hello, everybody!
>=20
> I am using the C function clock() as a counter
> of number of ticks of my programm. I am newbie in benchmarking
> architectures so please let me know if i am the
> right thing. I am using a Ultra-Sparc 5
>=20
> thanks in advance!
>=20
> The function is described here:
>=20
> http://htmlhelp.sunsite.dk/page.php/9/ch22s03.html
>=20
> Leonardo
>=20
>=20
> "A gente s=F3 sabe bem aquilo que n=E3o entende".
> Guimar=E3es Rosa


clock() is OK, but I prefer all the extra data
that getrusage() provides, like the split
between user time and system time, messages
sent/recieved, etc.

At first you won't know which other stuff
that getrusage() gives you is important to
you or not, but you'll have the info without
having to swap our one subroutine call for
another.

NPL

--=20
"It is impossible to make anything foolproof
because fools are so ingenious"
- A. Bloch
Pete Brett

2004-06-20, 10:32 pm

Leonardo Barbosa e Oliveira <leob@dcc.ufmg.br> wrote:

>
>
>Hello, everybody!
>
>I am using the C function clock() as a counter
>of number of ticks of my programm. I am newbie in benchmarking
>architectures so please let me know if i am the
>right thing. I am using a Ultra-Sparc 5
>

I generally use time(1). It has the advantage that you need not alter any code
and that it gives a more detailed output of user and system time.

If you want to benchmark individual functions as opposed to your whole program
then you might be better using getruseage(). You could also look into using
gprof if it is available on your platform.

Pete
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com