# Thread: Help me to analyse!!!

1. Member Join Date
Mar 2009
Posts
16
Rep Power
0

## Help me to analyse!!!

I'm developing some algorithms using java.math.BigInteger and java.math.BigDecimal classes, but I have to analyze, how many computer operation is done when I use methods of these classes. For example I want to add value of the two BigInteger obejcts like 1234567890123456789012345678901234567890 and 9876543210987654321098765432109876543210 using BigInteger's add() method, so how many elementary computation is done to give me output? Or say in different how long does add() method takes, on computer with 1.000.000 elementary operations per second, to add those BigIntegers?  Reply With Quote

2. ## You want to know the time taken to do this, or how many operations take place in that calculation?

Do you know anything about Z80 or something low level language?  Reply With Quote

3. Member Join Date
Mar 2009
Posts
16
Rep Power
0

## Eranga, I do not know about Z80 low language. I need to know how many operations take place in that calculation. Can you advise me? I need result with equation, which include parameters of computer's frequency.  Reply With Quote

4. ## So you can think about the number of iteration you take to calculate those numbers, just build-up the logic first and added into an equation.  Reply With Quote

5. Member Join Date
Mar 2009
Posts
16
Rep Power
0

## So I wrote program:
import java.math.BigDecimal;
class Sqrt {
BigDecimal sqrt2() {
BigDecimal x = new BigDecimal("1");
BigDecimal a = new BigDecimal("0");
BigDecimal ikki = new BigDecimal("2");
BigDecimal yarim = new BigDecimal("0.5");
for (int i=0; i<=7; i++) {
a=ikki.divide(x, 300, 0);
x=x.add(a);
x=x.multiply(yarim);
}
return x;
}
}

class SquareRoot {
public static void main(String args[]) {
Sqrt sqrt = new Sqrt();
System.out.println(sqrt.sqrt2());
}
}
Look at
a=ikki.divide(x, 300, 0);
x=x.add(a);
x=x.multiply(yarim);
I do not know how many operations ,for example, in method add(), because it's different simple plus (+). What do you think?

I don't need this (the fragment gives result how many time program worked):
long t1 = System.currentTimeMillis();
x=x.add(a);
long time = System.currentTimeMillis() - t1;

Sorry for my poor english...  Reply With Quote

6. Member Join Date
Mar 2009
Posts
16
Rep Power
0

## Nobody wants to help me... :(  Reply With Quote

7. ## Olim:
What you are looking for is the number of machine cycles for each command? Part of what your looking for is the assembler commands (low lelvel) equivalent of those operations (try Google). You are correct in stating that System.currentTimeMillis() is not what you are looking for. The only thing I can think of is using a dissambler. DOS comes with one (not in the help) called "debug" , but I used so long ago, I have forgotten what it all does (again try Google with "DOS debug commands"). But to understand what your looking for you would have to understand the assembler language.

Luck,
CJSL  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•