# Help me to analyse!!!

• 03-04-2009, 10:11 AM
OlimRashidovich
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?
• 03-04-2009, 11:03 AM
Eranga
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?
• 03-04-2009, 11:12 AM
OlimRashidovich
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.
• 03-04-2009, 11:27 AM
Eranga
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.

• 03-04-2009, 11:33 AM
OlimRashidovich
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.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.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();