Nice TWiki > Doc > CodeExamples > DispatchIntermediateExample (r1.1) TWiki webs:
Dev | Doc | Main | TWiki | Sandbox
Doc . { Changes | Index | Search | Go }
The original MultiJava code for this benchmark, and the Java comparison code, is available from this Technical Report: "MultiJava: Design, implementation, and evaluation of a Java-compatible language supporting modular open classes and symmetric multiple dispatch", Curtis Clifton, Iowa State University TR #01-10, November 2001.

Curtis Clifton kindly gave permission for this use.

The performance ratios for MultiJava and Nice are very different - the results are from different machines, and different test iterations but that doesn't seem like an adequate explanation.

MultiJava 1,000,000 loops: 140ms
  Java double-dispatch Java typecases
  2,704ms 4,307ms
multiple-dispatch 4,306ms 4,306ms
speedup 0.627 1.000

Nice 0.9.2 1,000,000 loops: 47-63ms
  100,000,000 loops: 4,672ms
  Java double-dispatch Java typecases
  123,125ms 108,641ms
multiple-dispatch 122,844ms 122,844ms
speedup 1.002 0.884

Multiple Dispatch

The typecases and double-dispatch implementations are given in the MultiJava report. A single line was changed in both of the Java test driver classes and (to call the Nice multi-dispatch method):

Real result = values[i].multiply1(values[j]);
was changed to
Real result = dispatch.multiply1(values[i],values[j]);

The multi-dispatch methods were placed together in a separate file. That is different to the MultiJava implementation:

// compilation unit multiply1.nice
package multipledispatch;

import multipledispatch.*;

// Methods using multiple dispatch

Real multiply1(Real this, Real other);

multiply1(this@Real, other@Real) = 
   new Real(this.value * other.value());

multiply1(this@Integer, other@Integer) = 
   new Integer(lValue * other.getLValue() );

multiply1(this@Integer, other@Rational) = 
   new Rational(lValue * other.numerator(), other.denominator() );

multiply1(this@Rational, other@Integer) =
   new Rational( this.numerator * other.getLValue(), 
                 this.denominator ); 

multiply1(this@Rational, other@Rational) =
   new Rational( this.numerator * other.numerator(), 
                 this.denominator * other.denominator() );
long getLValue(Integer) = native long multipledispatch.Integer.lValue();

-- IsaacGouy - 19 Sep 2003

Topic DispatchIntermediateExample . { Edit | Attach | Ref-By | Printable | Diffs | r1.2 | > | r1.1 | More }
Revision r1.1 - 19 Sep 2003 - 22:59 GMT - IsaacGouy
Parents: WebHome > CodeExamples
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback.