Browse Source

SC: additional timing code

tags/v1.3.0
Brian Heim 5 years ago
parent
commit
96dd05c3e1
1 changed files with 12 additions and 0 deletions
  1. +12
    -0
      src/SuperColliderEngine.cpp

+ 12
- 0
src/SuperColliderEngine.cpp View File

@@ -9,6 +9,7 @@


#include <thread> #include <thread>
#include <atomic> #include <atomic>
#include <numeric>
#include <unistd.h> // getcwd #include <unistd.h> // getcwd


// SuperCollider script engine for VCV-Prototype // SuperCollider script engine for VCV-Prototype
@@ -314,6 +315,9 @@ void SC_VcvPrototypeClient::fail(const std::string& msg) noexcept {


// TODO test code // TODO test code
static long long int gmax = 0; static long long int gmax = 0;
static constexpr unsigned int nTimes = 1024;
static long long int times[nTimes] = {};
static unsigned int timesIndex = 0;


void SC_VcvPrototypeClient::evaluateProcessBlock(ProcessBlock* block) noexcept { void SC_VcvPrototypeClient::evaluateProcessBlock(ProcessBlock* block) noexcept {
// TODO timing test code // TODO timing test code
@@ -323,11 +327,19 @@ void SC_VcvPrototypeClient::evaluateProcessBlock(ProcessBlock* block) noexcept {
readScProcessBlockResult(block); readScProcessBlockResult(block);
auto end = std::chrono::high_resolution_clock::now(); auto end = std::chrono::high_resolution_clock::now();
auto ticks = (end - start).count(); auto ticks = (end - start).count();

times[timesIndex] = ticks;
timesIndex++;
timesIndex %= nTimes;
if (gmax < ticks) if (gmax < ticks)
{ {
gmax = ticks; gmax = ticks;
printf("MAX TIME %lld\n", ticks); printf("MAX TIME %lld\n", ticks);
} }
if (timesIndex == 0)
{
printf("AVG TIME %lld\n", std::accumulate(std::begin(times), std::end(times), 0ull) / nTimes);
}
} }


int SC_VcvPrototypeClient::getResultAsInt(const char* text) noexcept { int SC_VcvPrototypeClient::getResultAsInt(const char* text) noexcept {


Loading…
Cancel
Save