Created
March 20, 2017 12:45
-
-
Save fedden/9dbe749436b4b3a72a15d5d882e2e8e3 to your computer and use it in GitHub Desktop.
Maxi Object Timing Check
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
#include <iostream> | |
#include "/home/tollie/Development/Maximilian/maximilian.h" | |
#include <vector> | |
#include <algorithm> | |
#include <chrono> | |
size_t amount = 1; | |
std::vector<maxiOsc> maxiObjects; | |
void process() | |
{ | |
for (int i = 0; i < maxiObjects.size(); ++i) | |
{ | |
double currentOut = maxiObjects[i].sinewave(440); | |
} | |
} | |
int main(int argc, char *argv[]) | |
{ | |
bool done = false; | |
std::vector<bool> takenTooLong; | |
const double runTimeSeconds = 1.0; | |
const auto limit = (long long) maxiSettings::sampleRate * runTimeSeconds; | |
const long long frameTimeLimitMicro = (long long) (1.0 / maxiSettings::sampleRate * 1000000.0); | |
while (!done) | |
{ | |
std::cout << "Amount = " << amount << std::endl; | |
maxiObjects.clear(); | |
maxiObjects.resize(amount); | |
for (size_t i = 0; i < amount; ++i) | |
maxiObjects[i] = maxiOsc(); | |
takenTooLong.clear(); | |
takenTooLong.resize(limit); | |
for (size_t i = 0; i < limit; ++i) | |
takenTooLong[i] = false; | |
auto count = limit; | |
while (--count >= 0) | |
{ | |
auto start = std::chrono::high_resolution_clock::now(); | |
process(); | |
auto elapsed = std::chrono::high_resolution_clock::now() - start; | |
long long microseconds = std::chrono::duration_cast<std::chrono::microseconds>(elapsed).count(); | |
takenTooLong[count] = (microseconds > frameTimeLimitMicro); | |
if (takenTooLong[count]) | |
{ | |
std::cout << microseconds << std::endl; | |
std::cout << frameTimeLimitMicro << std::endl; | |
} | |
} | |
done = std::any_of(takenTooLong.begin(), takenTooLong.end(), [] (bool b) | |
{ | |
return b == true; | |
}); | |
amount++; | |
} | |
std::cout << "\n\nDone!\n\nMaximum working amount = " << amount << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment