Applet Timing Tests

The links below go to applet interfaces to Kernighan and Wyk's Java timing tests. For more information, see
  • 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 implements a class that runs the sumloop class.

    The test specific applet class has the following methods:

    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
    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.
    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.
    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

    <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");
     <FORM NAME="jstest">
    Number of JavaScript Iterations:
     <INPUT TYPE="text" NAME="jsloops" VALUE="1">
     <INPUT TYPE="button" VALUE="Start tests under JavaScript"
    When the button is pressed, the plotsumloop JavaScript method is run.
    function plotsumloop(loops) {
        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
    	    // Plot the results
    	    // Print the results in the TextView
                document.Sumloop.output.appendText(i + " " + r + "\n");
                if (connected == false)
        document.Sumloop.output.appendText("# Done with JavaScript sumloop\n");


    For more information about Ptplot, see


  • 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