Skip to content

Instantly share code, notes, and snippets.

@jamiebullock
Created March 20, 2017 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiebullock/02d714f56aa9bc922351a3d41cbef4ce to your computer and use it in GitHub Desktop.
Save jamiebullock/02d714f56aa9bc922351a3d41cbef4ce to your computer and use it in GitHub Desktop.
Test for JUCE connecting to a remote URL
#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