int main(int argc, char* argv[]) { clock_t start, stop; start = clock(); //int v = atoi(argv[1]); int v = 10; // nicer for IDE/Profiler std::cout << "The random seed is: " << v << std::endl; srand(v); GenRandGenerator randGenerator; LevelGenerator<GenRandGenerator> levelGenerator( randGenerator, NUM_LEVS ); std::vector<std::thread> threads; threads.reserve( NUM_THREADS ); for( uint32_t i = 0 ; i < NUM_THREADS ; ++i ) { uint32_t threadSeed = v * ((i+1)*(i+1)); std::cout << "The seed of thread " << i << " is: " << threadSeed << std::endl; uint32_t partitionStartIndex( i * NUM_LEVS_PER_THREAD ); uint32_t partitionEndIndex( partitionStartIndex + NUM_LEVS_PER_THREAD ); threads.emplace_back(std::bind( &LevelGenerator<GenRandGenerator>::partitionedGenerateLevels, &levelGenerator, threadSeed, partitionStartIndex, partitionEndIndex )); } for( uint32_t i = 0 ; i < NUM_THREADS ; ++i ) { threads[i].join(); } NumRoomsMetric numRoomsMetric; Level & l( levelGenerator.pickLevelByCriteria( numRoomsMetric ) ); printLevel( l ); stop = clock(); long clocks_per_ms = CLOCKS_PER_SEC/1000; std::cout << (stop - start)/clocks_per_ms << std::endl; return 0; }
int main(int argc, char* argv[]) { clock_t start, stop; start = clock(); int v = atoi(argv[1]); printf("The random seed is: %d \n", v); srand(v); GenRandGenerator randGenerator( v ); LevelGenerator<GenRandGenerator> levelGenerator( randGenerator ); levelGenerator.generateLevels(); NumRoomsMetric numRoomsMetric; Level & l( levelGenerator.pickLevelByCriteria( numRoomsMetric ) ); printLevel( l ); stop = clock(); long clocks_per_ms = CLOCKS_PER_SEC/1000; printf("%ld\n", (stop - start)/clocks_per_ms); return 0; }