netsurf/test/js/js-fractal.html
Michael Drake 4b0ebae56a Add a couple of general JS tests.
The primes one prints its execution time:

  NetSurf without -v: 1300ish
             with -v: 5000ish
      Firefox 38.5.0:  300ish
2016-01-23 10:32:26 +00:00

42 lines
947 B
HTML

<!DOCTYPE html>
<html>
<head>
<title>JavaScript mandelbrot set</title>
<style>pre {font-size:8pt;}</style>
</head>
<body>
<h1>JavaScript generated mandelbrot set</h1>
<script>
function show_mandelbrot()
{
var gradation = " .,:;=|i+IhHOE#$ ";
document.writeln("<pre>");
for(i = -1.2; i <= 1.2; i += 0.04) {
for(r = -2; r <= 1; r += 0.02) {
var zr = r;
var zi = i;
var n = 0;
for(; n < 16; n++) {
var zr2 = zr * zr;
var zi2 = zi * zi;
if((zr2 + zi2) > 4) {
break;
}
zi = 2 * zr * zi + i;
zr = zr2 - zi2 + r;
}
document.write(gradation.charAt(n));
}
document.write("\n");
}
document.writeln("</pre>");
document.close();
}
show_mandelbrot();
</script>
<noscript>
JavaScript not enabled.
</noscript>
</body>
</html>