harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Evgeniya Maenkova (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-3088) [math]java.math.BigDecimal/java.math.BigInteger.equals improvement
Date Tue, 30 Jan 2007 15:13:33 GMT
[math]java.math.BigDecimal/java.math.BigInteger.equals improvement
------------------------------------------------------------------

                 Key: HARMONY-3088
                 URL: https://issues.apache.org/jira/browse/HARMONY-3088
             Project: Harmony
          Issue Type: Improvement
          Components: Classlib
            Reporter: Evgeniya Maenkova
         Attachments: math.equals.patch

BigDecimal.equals/BigInteger.equals can be implemented more effectively, if:
1) in BigInteger: split equals and compareTo operations (equls implemented by compareTo now);
2) remove redudant type cast in BigDecimal;
3) add primititve comparing at the beginning of equals methods (I mean if objects are the
same).

I've written minimal test case and see this impovement in terms of time:
current java.math:~44 sec;

patched java.math:~18 sec.
(I used my laptop so it's pretty approximately). 


Test mentioned above is (also to be attached):
import java.math.BigDecimal;

public class Equals {
    public static void main(String[] args) {
		BigDecimal[] values = new BigDecimal[100000];		
		for (int i = 0; i < values.length; i ++) {
			String s = i + "000" + i + "222" + i + "333." + i + "444";
			values[i] = new BigDecimal(s);
		}
		
		long start = System.currentTimeMillis();
		for (int i = 0; i < 1000; i ++) {
			for (int j = 0; j < values.length; j ++) {
				values[j].equals(values.length - j - 1);
				values[j].equals(values[j]);
			}
		}		
		
		System.out.println(System.currentTimeMillis() - start);
	}
}



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message