Created
April 1, 2022 10:12
-
-
Save creaktive/5e9c34466287bc8553b1472f1fdf25ae to your computer and use it in GitHub Desktop.
pianolizer benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* wget https://github.com/creaktive/pianolizer/raw/master/cpp/pianolizer.hpp | |
* g++ -Ofast -std=c++14 -o benchmark benchmark.cpp | |
*/ | |
#include <chrono> | |
#include <iostream> | |
#include <stdlib.h> | |
#include "pianolizer.hpp" | |
using namespace std; | |
int main() { | |
const unsigned SAMPLE_RATE = 44100; | |
auto sdft = SlidingDFT(make_shared<PianoTuning>(SAMPLE_RATE), -1.); | |
const unsigned bufferSize = 128; | |
float input[bufferSize]; | |
const float *output = nullptr; | |
auto start = chrono::high_resolution_clock::now(); | |
unsigned i; | |
for (i = 0; i < bufferSize * 10000; i++) { | |
unsigned j = i % bufferSize; | |
input[j] = ((i % 100) / 50.) - 1.; | |
if (j == bufferSize - 1) | |
output = sdft.process(input, bufferSize, .05); | |
} | |
auto end = chrono::high_resolution_clock::now(); | |
chrono::duration<double> elapsed = end - start; | |
cerr << "# benchmark: " << static_cast<int>(round(i / elapsed.count())) << " samples per second" << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment