Ejemplo n.º 1
0
int main(int argc, char** args) {
	int threads = 1;
	if(argc == 2) {
		sscanf(args[1], "%i", &threads);
		if(threads < 1) {
			printf("Threads must be greater 1.\n");
			return 1;
		}
	}
	printf("Running profile tests on %i threads\n", threads);
	ERRCHECK(Lav_initialize());
	for(int i = 0; i < to_profile_size; i++) {
		auto &info = to_profile[i];
		printf("Estimate for %s nodes: ", std::get<0>(info).c_str());
		LavHandle s;
		ERRCHECK(Lav_createServer(SR, BLOCK_SIZE, &s));
		ERRCHECK(Lav_serverSetThreads(s, threads));
		int times=std::get<1>(info);
		//If it's not at least threads, make it threads.
		if(times < threads) times = threads;
		auto handles=std::get<2>(info)(s, times);
		for(auto h: handles) {
			ERRCHECK(Lav_nodeConnectServer(h, 0));
		}
		float dur=timeit([&] () {
			ERRCHECK(Lav_serverGetBlock(s, 2, 1, storage));
		}, ITERATIONS);
		dur /= ITERATIONS;
		float estimate = (BLOCK_SIZE/(float)SR)/dur*times;
		printf("%f\n", estimate);
		for(auto h: handles) {
			ERRCHECK(Lav_nodeDisconnect(h, 0, 0, 0));
			ERRCHECK(Lav_handleDecRef(h));
		}
		ERRCHECK(Lav_handleDecRef(s));
	}
}
Ejemplo n.º 2
0
void main(int argc, char** args) {
	int threads = 1;
	if(argc == 2) {
		sscanf(args[1], "%i", &threads);
		if(threads < 1) {
			printf("Threads must be greater 1.\n");
			return;
		}
	}
	printf("Running profile tests on %i threads\n", threads);
	ERRCHECK(Lav_initialize());
	for(int i = 0; i < to_profile_size; i++) {
		auto &info = to_profile[i];
		printf("Estimate for %s nodes: ", std::get<0>(info).c_str());
		LavHandle sim;
		ERRCHECK(Lav_createSimulation(SR, BLOCK_SIZE, &sim));
		ERRCHECK(Lav_simulationSetThreads(sim, threads));
		int times=std::get<1>(info);
		//If it's not at least threads, make it threads.
		if(times < threads) times = threads;
		auto handles=std::get<2>(info)(sim, times);
		for(auto h: handles) {
			ERRCHECK(Lav_nodeSetIntProperty(h, Lav_NODE_STATE, Lav_NODESTATE_ALWAYS_PLAYING));
		}
		float dur=timeit([&] () {
			ERRCHECK(Lav_simulationGetBlock(sim, 2, 1, storage));
		}, ITERATIONS);
		dur /= ITERATIONS;
		float estimate = (BLOCK_SIZE/(float)SR)/dur*times;
		printf("%f\n", estimate);
		for(auto h: handles) {
			ERRCHECK(Lav_handleDecRef(h));
		}
		ERRCHECK(Lav_handleDecRef(sim));
	}
}