Created
March 20, 2017 15:19
-
-
Save jamiebullock/02d714f56aa9bc922351a3d41cbef4ce to your computer and use it in GitHub Desktop.
Test for JUCE connecting to a remote URL
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 "../JuceLibraryCode/JuceHeader.h" | |
int connect(const String& source) | |
{ | |
URL url(source); | |
ScopedPointer<WebInputStream> stream = url.createInputStream(false); | |
if (stream == nullptr) return -1; | |
return 0; | |
} | |
//============================================================================== | |
int main (int argc, char* argv[]) | |
{ | |
const std::string url = "https://s3.amazonaws.com"; | |
int iterations = 100; | |
double total_time = 0.0; | |
for (int i = 0; i < iterations; ++i) | |
{ | |
DBG("****** Running test " << i << " ******"); | |
auto start = std::chrono::steady_clock::now(); | |
connect(url); | |
auto end = std::chrono::steady_clock::now(); | |
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - start); | |
float time_secs = elapsed.count() / 1000.0; | |
total_time += time_secs; | |
DBG("Time: " << time_secs); | |
} | |
DBG("AVERAGE " << total_time / (float)iterations); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment