>  public class test
>  {

See http://blogs.sun.com/jrose/entry/longjumps_considered_inexpensive
for some notes on exceptions and performance. Try this change:
public class test_reuse
{
        public static final Exception EXCEPTION = new Exception("") { public
Throwable fillInStackTrace(){return null; } };
   int foo(int n)
   {
     return n - 1;
   }

   void bar()
   {
   }

   void baz()
   {
   }

   void run()
   {
       //Exception e = new Exception("");
       try
       {
           for (int i=0; i<3; ++i)
           {
               if (foo(i) == 0) throw EXCEPTION;
           }
       }
       catch (Exception e2)
       {
       }
       bar();
       baz();
   }

   public static void main(String[] args)
   {
       for (int n=0; n<10; ++n)
       {
           long start = System.currentTimeMillis();
           for (int i=0; i<1000000; ++i)
               (new test_reuse()).run();
           System.out.println(System.currentTimeMillis() - start);
       }
   }
}

also, baz() and bar() are noise in this benchmark, as they should be
dropped by the JVM as no-ops.

[EMAIL PROTECTED]:~/tmp$
>java -cp . test
1572
1575
1570
1572
1576
1572
1603
1614
1575
1576
[EMAIL PROTECTED]:~/tmp$
>java -cp . -server test
1480
1457
1468
1461
1470
1456
1459
1464
1455
1456
[EMAIL PROTECTED]:~/tmp$
>java -cp . test_reuse
133
127
129
129
132
129
130
128
128
127
[EMAIL PROTECTED]:~/tmp$
>java -cp . -server test_reuse
25
12
10
9
10
10
8
9
9
9
[EMAIL PROTECTED]:~/tmp$
>java -version
java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05-237)
Java HotSpot(TM) Client VM (build 1.5.0_13-119, mixed mode, sharing)

IMO, this discussion is becoming a bit of a food fight, which is
unnecessary and not really useful. You have points to make, Jon, but
everyone throwing benchmarks at each other usually just wastes time.
There are better forums to discuss these things.

Cheers!
Patrick

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to