Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2009
    Posts
    16
    Rep Power
    0

    Default 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?

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    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?

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

    Default

    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.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    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.


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

    Default

    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...

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

    Default

    Nobody wants to help me... :(

  7. #7
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default

    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
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Posting Permissions

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