![](https://seccdn.libravatar.org/avatar/2e9da05addf868f6fc2eb2e1ff6dc3b9.jpg?s=120&d=mm&r=g)
I wonder whether SuSE has some tool / system call to help with C programs performance tests. Basically I'd like to check whether certain ad-hoc algorithms really improve my simulation performances in terms of time and CPU usage. Thank you in advance for your help. MEM
![](https://seccdn.libravatar.org/avatar/4f9b9b9399b329591f7be92da1c5e442.jpg?s=120&d=mm&r=g)
I wonder whether SuSE has some tool / system call to help with C programs performance tests. Basically I'd like to check whether certain ad-hoc algorithms really improve my simulation performances in terms of time and CPU usage.
Thank you in advance for your help.
MEM I'm not aware of any specific to SuSE. Without more details of your requirements, I'd start by suggesting you should be familiar with the usual
On Sunday 24 March 2002 14:18, Maura Edelweiss wrote: linux/unix tools, like vmstat, top, gprof, the various time programs (shell time and /usr/bin/time). Then consider library timing calls, like clock(), gettimeofday(), and low level calls for the CPU family of your choice, like rdtsc for i386. If an evaluation version of Intel Vtune http://www.intel.com/software/products/vtune/vtune60/index.htm comes with a future SuSE, that would be something shared by relatively few distros. -- Tim Prince
![](https://seccdn.libravatar.org/avatar/8ce4efecf1119dcbfc03135ad33fee46.jpg?s=120&d=mm&r=g)
Maura Edelweiss wrote:
I wonder whether SuSE has some tool / system call to help with C programs performance tests. Basically I'd like to check whether certain ad-hoc algorithms really improve my simulation performances in terms of time and CPU usage.
Try # man rusage It's typically accurate to about 1/10 second. Typically I would test two versions of an algorithm and use this to estimate the approximate difference in CPU usage. Here's an example C program you can try this with. #include<stdio.h> #include<sys/resource.h> double factorial( int x ){ return x == 0 ? 1 : x * factorial( x - 1 ); } int main(){ int h, i; double f; struct rusage resource_usage; for( h = 0; h < 10000; h++ ) for( i = 0; i < 100; i++ ) f = factorial( i ); getrusage( RUSAGE_SELF, &resource_usage ); printf( "Approximate CPU time taken was %ld.%06ld seconds:\n", resource_usage.ru_utime.tv_sec, resource_usage.ru_utime.tv_usec ); exit( 0 ); } JDL
participants (3)
-
John Lamb
-
Maura Edelweiss
-
Tim Prince