Applet Timing Tests

The links below go to applet interfaces to Kernighan and Wyk's Java timing tests. For more information, see http://ptolemy.eecs.berkeley.edu/~cxh/java/tclblend/performance
  • sumloop
  • ack
  • array1
  • string
  • assoc
  • The applets are implemented as follows:

    TextPlotApplet is a common base class that includes a TextArea component and a Ptplot component.

    Test specific Applet class

    Each applet has its own class that sets up the Ptplot component and runs the test. For example SumloopApplet.java implements a class that runs the sumloop class.

    The test specific applet class has the following methods:

    addPoint
    This method is used by the JavaScript version of the test to plot the JavaScript data on the applet's Ptplot component. If there is no JavaScript version of the test, then there is no need for a addPoint method
    init
    This method instantiates a Plot and sets the timeplot variable of the parent class. This method also sets the title and other attributes of the plot.
    runTest
    This method is called by the TextPlotApplet class when the button is pressed. This method sets the busy cursor, reads the _loopField entry widget and then calls runOneTest for each test data point.
    runOneTest
    This method runs each test for a user specified number of loops by instantiating an object and then calling a method. In general, the method that is being timed should return the amount of time it took.

    Timing JavaScript

    The JavaScript tests plot their results in the applet's Ptplot component. The JavaScript tests use common code in ../js/timing.js

    Each HTML file has code that looks like

    <html>
    <head>
    <title>Sumloop Applet</title>
    <script src="../js/timing.js">
    <!-- Begin to hide script contents from old browsers.
    // End the hiding here. -->
    document.write("Included JS file not found");
    </script>
    </head>
    ...
    
     <FORM NAME="jstest">
    Number of JavaScript Iterations:
     <INPUT TYPE="text" NAME="jsloops" VALUE="1">
     <INPUT TYPE="button" VALUE="Start tests under JavaScript"
    	onClick="plotsumloop(this.form.jsloops)">
     </FORM>
    
    When the button is pressed, the plotsumloop JavaScript method is run.
    function plotsumloop(loops) {
        n=loops.value;
        connected=false;
        document.Sumloop.output.appendText("Dataset: JavaScript sumloop\n");
        document.Sumloop.output.appendText("# "+n+": 125000 - 1000000\n");
        for(i=125000; i <= 1000000; i = i*2) {
            for(j=0;j<n;j++) {
    	    // Run the test
                r=sumloop(i);
    	    // Plot the results
                document.Sumloop.addPoint(0,i,r,connected);
    	    // Print the results in the TextView
                document.Sumloop.output.appendText(i + " " + r + "\n");
                if (connected == false)
                    connected=true;
            }
        }
        document.Sumloop.output.appendText("# Done with JavaScript sumloop\n");
    }
    

    Ptplot

    For more information about Ptplot, see http://ptolemy.eecs.berkeley.edu/java/ptplot

    Limitations

  • The other tests are not implemented as applets because they read external files so the applet times would really reflect the speed of the network instead of the speed of the browser.
  • Only the sumloop and ack tests have JavaScript versions.
  • Some of the tests seem to take 0 time under some browsers. This could be a result of Just In Time compilation or someother form of optimization.

  • Copyright © 1998, The Regents of the University of California. All rights reserved.
    Last updated: 10/09/05, comments to: cxh at eecs