Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 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;
    }
I know the inner loop runs n times each time the main loop runs. But I can't figure out how to determine the number of times the main loop runs in any sort of formulaic way.

Yes, it's homework, but 90% of the assignment was developing and writing the algorithm.
Thanks
RAGEAngel9 is offline  
Old 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--
vinaur is offline  
Old 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
theFez is offline  
Old 04-15-2005, 01:15 PM   #4 (permalink)
Dreams In Digital
 
SiNai's Avatar
 
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
SiNai is offline  
 

Tags
algorithm, timing

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 03:58 AM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57