commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: [general] Performance testing oddity
Date Mon, 20 Jan 2003 13:28:55 GMT
Howdy,

>Test class #2)
>public static void main(String[] args) {
>  Map map = new HashMap();
>  map.put("AAA");
>  map.put("BBB");
>  map.put("CCC");
>
>  test(map);
>}
>private static void test(Map map) {
>  long start = 0;
>  long end = 0;
>
>  start = System.currentTimeMillis();
>  for (int i = RUNS; i >= 0; i--) {
>    map.get("AAA");
>    map.get("BBB");
>    map.get("CCC");
>  }
>  end = System.currentTimeMillis();
>  System.out.println(end - start);
>}
>
>These two classes give very different results. The refactored version
#2 is
>much slower, between 20% and 80% depending on the type of Map.
>
>Am I missing something obvious???
>[Sun JDK 1.4.1_01 (client or server)]

I don't think you're missing something obvious.  But out of curiosity,
if you mark the test(Map) method final, does the performance come out
equal to version #1 of your class?  It should, as the 1.4.1 compiler
will inline the method.

Also, does the 20% difference reduce when you increase RUNS?  If RUNS is
a very small value, then the method invocation overhead can actually be
pretty high when compared to the run itself.  Make RUNS 100000 and
measure the difference between the classes again, if you haven't done so
already...

Yoav Shapira
Millennium ChemInformatics

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message