diff --git a/simulation/main.cpp b/simulation/main.cpp index 48e8758b71b8e46b567454b730dfe7be4fc84e16..9724581933294188cdd5239cab46a0ca0386b2a0 100644 --- a/simulation/main.cpp +++ b/simulation/main.cpp @@ -1,9 +1,9 @@ -// To compile with -std=c++0x +// To compile : g++ -std=c++0x results.cpp graph.cpp main.cpp -lpthread #include "main.h" #include +#include +#include -int n = 1000; // the number of peer -int k = 10; // each peer try to make k connections with the others const char* outName = "out.csv"; @@ -13,9 +13,6 @@ Results Simulate(mt19937 rng, int n, int k, int maxPeer, int maxDistanceFrom, i for(int r=0; r> outputStrings; for(int n=200; n<=20000; n*=2) for(int k=5; k<=50; k+=5) { - Results results = Simulate(rng, n, k, 3*k, 10000, 50); - output << n << "," << k << "," << 3*k << "," << results.avgDistance << "," - << results.disconnected << "," << results.maxDistance << "," - << results.arityDistrib[3*k] << endl; + outputStrings.push_back(async(launch::async, [rng, n, k]() + { + Results results = Simulate(rng, n, k, 3*k, 10000, 50); + ostringstream out; + out << n << "," << k << "," << 3*k << "," << results.avgDistance << "," + << results.disconnected << "," << results.maxDistance << "," + << results.arityDistrib[3*k]; + + return out.str(); + })); } + cout << "Launching finished" << endl; + + int nTask = outputStrings.size(); + for(int i=0; i