changeset 2:44f670784d5f

Test jsfft
author Chris Cannam
date Thu, 01 Oct 2015 17:33:28 +0100
parents 1c027151f7ec
children b3243c84ccb3
files fft/test.html
diffstat 1 files changed, 36 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/fft/test.html	Thu Oct 01 16:56:01 2015 +0100
+++ b/fft/test.html	Thu Oct 01 17:33:28 2015 +0100
@@ -1,4 +1,5 @@
     <html>
+<meta charset="UTF-8">
     <body>
     <p>If 2150 iterations of real-to-complex FFT of size 2048 takes less than 10 seconds, then we may be able to make a high quality real-time phase vocoder (just).</p>
 
@@ -14,7 +15,7 @@
 <p>2150 iterations corresponds to 100 seconds of audio non-overlapped at
 44.1kHz, so if that takes less than 10 second, then in theory we might
 be OK.</p>
-    <pre>
+
 <script src="nayuki/fft.js"></script>
 <script>
 
@@ -62,7 +63,7 @@
 
 var end = performance.now();
 
-document.write("nayuki fft.js: " + iterations + " iterations at size " + size + " took " + (end - start) + "ms (" + (1000.0 / ((end - start) / iterations)) + " iterations/sec)<br>");
+document.write("nayuki fft.js: " + iterations + " iterations at size " + size + " took " + (end - start) + "ms (" + (1000.0 / ((end - start) / iterations)) + " iterations/sec)<br><br>");
 
 </script>
 <script src="fft.js/lib/complex.js"></script>
@@ -87,9 +88,40 @@
 
 var end = performance.now();
 
-document.write("nockert fft.js: " + iterations + " iterations at size " + size + " took " + (end - start) + "ms (" + (1000.0 / ((end - start) / iterations)) + " iterations/sec)<br>");
+document.write("nockert fft.js: " + iterations + " iterations at size " + size + " took " + (end - start) + "ms (" + (1000.0 / ((end - start) / iterations)) + " iterations/sec)<br><br>");
 
     </script>
-</pre>
+<script src="jsfft/lib/complex_array.js"></script><script src="jsfft/lib/fft.js"></script>
+<script>
+
+function inputComplexArray(size) {
+    var result = new complex_array.ComplexArray(size);
+    for (var i = 0; i < size; i++) {
+	result.real[i] = (i % 20) / 10.0 - 1.0;
+	result.imag[i] = 0.0;
+    }
+    return result;
+}
+
+start = performance.now();
+
+total = 0.0;
+
+for (var i = 0; i < iterations; ++i) {
+    var ci = inputComplexArray(size);
+    var co = ci.FFT();
+    for (var j = 0; j < size; ++j) {
+	total += co.real[j] + co.imag[j];
+    }
+}
+
+document.write("total = " + total + "<br>");
+
+var end = performance.now();
+
+document.write("dntj jsfft: " + iterations + " iterations at size " + size + " took " + (end - start) + "ms (" + (1000.0 / ((end - start) / iterations)) + " iterations/sec)<br><br>");
+
+</script>
+
     </body>