コード例 #1
0
std::string save_path(int idx)
{
	int swarm_id = test_counter();
	char path[200];
	std::snprintf(path, sizeof(path), "swarm-%04d-peer-%02d"
		, swarm_id, idx);
	return path;
}
コード例 #2
0
ファイル: pc_test.c プロジェクト: llj098/PerfCounter
int main()
{
	int i ;

	for(i= 10; i< 1000 * 1000; i = i *10) {
		printf("## interval %d\n", i);
		test_counter(i);
	}

	return 0;
}
コード例 #3
0
lt::add_torrent_params create_torrent(int const idx, bool const seed
	, int const num_pieces)
{
	// TODO: if we want non-seeding torrents, that could be a bit cheaper to
	// create
	lt::add_torrent_params params;
	int swarm_id = test_counter();
	char name[200];
	std::snprintf(name, sizeof(name), "temp-%02d", swarm_id);
	std::string path = save_path(idx);
	lt::error_code ec;
	lt::create_directory(path, ec);
	if (ec) std::fprintf(stderr, "failed to create directory: \"%s\": %s\n"
		, path.c_str(), ec.message().c_str());
	std::ofstream file(lt::combine_path(path, name).c_str());
	params.ti = ::create_torrent(&file, name, 0x4000, num_pieces + idx, false);
	file.close();

	// by setting the save path to a dummy path, it won't be seeding
	params.save_path = seed ? path : "dummy";
	return params;
}