commit 6cdfa4cfbba120c3b3763cbfc5b28809ab04ac2f
parent 74a6f07edaab540b5e482fed4f4b2835deacd11c
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date: Wed, 15 Jan 2014 17:45:09 -0800
Kick off performance regression testing
Diffstat:
3 files changed, 99 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
@@ -41,6 +41,8 @@ po/stamp-it
src/*.stamp
src/spek
stamp-h1
+tests/perf
+tests/samples/perf.wav
tests/test
web/version
xmldocs.make
diff --git a/tests/Makefile.am b/tests/Makefile.am
@@ -1,4 +1,6 @@
-TESTS = test
+TESTS = \
+ test \
+ perf
if USE_VALGRIND
TESTS_ENVIRONMENT = valgrind --leak-check=full --quiet --error-exitcode=1
@@ -6,6 +8,9 @@ endif
check_PROGRAMS = $(TESTS)
+perf_SOURCES = \
+ perf.cc
+
test_SOURCES = \
test-audio.cc \
test-fft.cc \
diff --git a/tests/perf.cc b/tests/perf.cc
@@ -0,0 +1,91 @@
+/* perf.cc
+ *
+ * Copyright (C) 2013-2014 Alexander Kojevnikov <alexander@kojevnikov.com>
+ *
+ * Spek is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Spek is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Spek. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <cstdlib>
+#include <iostream>
+#include <fstream>
+
+const char *SAMPLE_FILE = SAMPLES_DIR "/perf.wav";
+const int SAMPLE_RATE = 44100;
+const int SAMPLE_DURATION = 8 * 60; // 8 minutes
+const int SAMPLES = SAMPLE_RATE * SAMPLE_DURATION; // per channel
+
+// Some of the tests will use a sample .wav file which is auto-generated if it doesn't exists.
+static void create_samples()
+{
+ if (std::ifstream(SAMPLE_FILE).good()) {
+ return;
+ }
+
+ std::ofstream file(SAMPLE_FILE, std::ofstream::binary);
+ const int data_size = SAMPLES * 2 * 2; // samples * channels * bytes per sample
+ uint16_t u16;
+ uint32_t u32;
+ file.write("RIFF", 4);
+ file.write(reinterpret_cast<const char*>(&(u32 = 36 + data_size)), 4); // size
+ file.write("WAVE", 4);
+ file.write("fmt ", 4);
+ file.write(reinterpret_cast<const char*>(&(u32 = 16)), 4); // subchunk size
+ file.write(reinterpret_cast<const char*>(&(u16 = 1)), 2); // 1 = PCM
+ file.write(reinterpret_cast<const char*>(&(u16 = 2)), 2); // 2 = stereo
+ file.write(reinterpret_cast<const char*>(&(u32 = SAMPLE_RATE)), 4);
+ file.write(reinterpret_cast<const char*>(&(u32 = SAMPLE_RATE * 2 * 2)), 4); // byte rate
+ file.write(reinterpret_cast<const char*>(&(u16 = 2 * 2)), 2); // block align
+ file.write(reinterpret_cast<const char*>(&(u16 = 16)), 2); // bits per sample
+ file.write("data", 4);
+ file.write(reinterpret_cast<const char*>(&(u32 = data_size)), 4);
+
+ // Fill in both channels with pseudo-random values.
+ srand(93);
+ for (int i = 0; i < SAMPLES * 2; ++i) {
+ file.write(reinterpret_cast<const char*>(&(u16 = rand())), 2);
+ }
+}
+
+// Reading and decoding an audio file.
+static void perf_decoder()
+{
+}
+
+// Running FFTs and processing the results.
+static void perf_worker()
+{
+}
+
+// Managing worker and decoder threads (in isolation from the actual decoder and worker).
+static void perf_pipeline()
+{
+}
+
+// Testing it all together.
+static void perf_all()
+{
+}
+
+// Performance regression tests.
+int main()
+{
+ create_samples();
+
+ perf_decoder();
+ perf_worker();
+ perf_pipeline();
+ perf_all();
+
+ return 0;
+}