Beispiel #1
0
int
main()
{
	struct pbc_slice slice;
	read_file("addressbook.pb", &slice);
	if (slice.buffer == NULL)
		return 1;
	struct pbc_env * env = pbc_new();
	pbc_register(env, &slice);

	free(slice.buffer);

	struct pbc_wmessage *msg = test_wmessage(env);

	pbc_wmessage_buffer(msg, &slice);

	dump(slice.buffer, slice.len);

	test_rmessage(env, &slice);

	pbc_wmessage_delete(msg);
	pbc_delete(env);

	return 0;
}
Beispiel #2
0
void testOldWrite()
{
	struct pbc_slice slice;
	read_file("addressbooknew.pb", &slice); //ClientSvrMsg
	//read_file("ClientSvrMsg.pb", &slice); //ClientSvrMsg
	if (slice.buffer == NULL)
		return 1;
	struct pbc_env * env = pbc_new();
	int r = pbc_register(env, &slice);
	if (r) {
		printf("Error : %s", pbc_error(env));
		return 1;
	}

	free(slice.buffer);

	struct pbc_wmessage *msg = test_wmessage(env);
	//struct pbc_wmessage *msg = test_ClientSevermessage(env);
	pbc_wmessage_buffer(msg, &slice);
	dump(slice.buffer, slice.len);
	FILE* f = fopen("test.bin", "wb");
	fwrite(slice.buffer, slice.len, 1, f);
	fclose(f);
	f = NULL;
}
Beispiel #3
0
int
main()
{
	struct pbc_slice slice;
	read_file("performance.pb", &slice);
	if (slice.buffer == NULL)
		return 1;
	struct pbc_env * env = pbc_new();
	int r = pbc_register(env, &slice);
	if (r) {
		printf("Error : %s", pbc_error(env));
		return 1;
	}

	free(slice.buffer);

	clock_t start = clock();
	int i;
	for ( i = 0;i < 1000000;i ++ )
	{
		struct pbc_wmessage *msg = test_wmessage(env);

		pbc_wmessage_buffer(msg, &slice);

		//dump(slice.buffer, slice.len);

		//test_rmessage(env, &slice);

		//if ( i == 100000 - 1) test_rmessage(env, &slice);
		pbc_wmessage_delete(msg);
	}

	clock_t t = clock() - start;
	printf( "time cost %f\n", ((float)t)/CLOCKS_PER_SEC );

	pbc_delete(env);

	return 0;
}