04-14-2005, 05:33 PM | #1 (permalink) |
Insane
Location: Vermont
|
Algorithm Timing
Hey guys quick question that I can't seem to get.
I'm trying to show how a program I wrote improves (or worsens) as the number of processors increases. However, I can't for the life of me determine a way to represent the time it take for one of the funcitons to run. Code:
double term = start; double newTerm = 0; double precision=1e-6; double sum = start; int i =0; // Calculate each new term and add to total //Stop when the previous term is less than the precision for( i = p;term > precision ; ) { double newFac = 1; // Calculate the nessesary jump given i and the (n)umber of processors for(int j = 1;j <= n ; j++ ) { newFac = newFac * ( x / ( i+ j )); } newTerm = newFac; //Get new term term = term * newTerm; // Increment sum by new term sum += term; i=i+n; } Yes, it's homework, but 90% of the assignment was developing and writing the algorithm. Thanks |
04-14-2005, 08:04 PM | #2 (permalink) |
Insane
|
Is this it, because I don't see any declarations for start, p and x. It would be nice to know what those are.
__________________
If you multiply that by infinity and take it to the depths of forever, you will, perhaps, get just a glimpse of what I am talking about. --Meet Joe Black-- |
04-14-2005, 08:21 PM | #3 (permalink) |
Crazy
Location: here and there
|
If you can use perl, there are some good benchmarking features in the benchmark module.
I've used them a few times to test performance of different algorithms. http://www.perldoc.com/perl5.8.0/lib/Benchmark.html
__________________
# chmod 111 /bin/Laden Last edited by theFez; 04-14-2005 at 08:22 PM.. Reason: link |
04-15-2005, 01:15 PM | #4 (permalink) |
Dreams In Digital
Location: Iowa
|
Are we talking theoretical big-oh stuff or empirical timing, or both? You can use System.currentTimeMillis() for actual timings in milliseconds.
Theoretical.. You're incrementing your outer loop by a constant? 0(n^2) then.. (Can't tell what n is..)
__________________
I can't seem to remember now What it was like- to live life, before you.. symbiont |
Tags |
algorithm, timing |
|
|