http://ptolemy.eecs.berkeley.edu/~cxh/java/tclblend/performance
The applets are implemented as follows:
TextPlotApplet is
a common base class that includes a TextArea component
and a Ptplot component.
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
addPoint method
init
Plot and sets the
timeplot variable of the parent class. This method
also sets the title and other attributes of the plot.
runTest
_loopField entry widget and then
calls runOneTest for each test data point.
runOneTest
../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");
}
For more information about Ptplot,
see
http://ptolemy.eecs.berkeley.edu/java/ptplot