Esempio n. 1
0
int main(int argc, char const *argv[])
{

	std::cout << "\n============= Performance Test ================\n";

	testSpeed("data/citm_catalog.json");
	testSpeed("data/webxml.json", 1000);

	std::cout << "(Download citylots.json (185MB) from Github https://github.com/zeMirco/sf-city-lots-json"
		"(zeMirco/sf-city-lots-json) and uncomment the following line.)\n";
//	testSpeed("data/citylots.json", 2);


	std::cout << "\n============= Error Handling Test =============\n";

	testErrorHandling("{");
	testErrorHandling("[");
	testErrorHandling("]");
	testErrorHandling("}");
	testErrorHandling("[}");
	testErrorHandling("[1, 2, []]");
	testErrorHandling("[1, 2");
	testErrorHandling("3e++5");
	testErrorHandling("3e309");
	testErrorHandling("[truk]");
	testErrorHandling("[fallse]");
	testErrorHandling("[nulll]");
	testErrorHandling("[\"hello\"]");
	testErrorHandling("[[1, [4, 5, [6] ,3]]");
	testErrorHandling("/ comment */  [1, 2, 3]");

	std::cout << "\n============= Serialization(Pretty Print) Test =============\n";

	testPrettyPrint("{\"number\" : [1,2,4,6,{\"string\":  \"foobar\"},7,5]}");
	testPrettyPrint("{\"UTF8ÖÐÎÄ\" : \"ÄÚÈÝ\" , \"UTF8\" : \"type\"}");


	std::cout << "\n============ Json operation(set/remove/find) Test ===========\n";
	try
	{
		EJ::JSON j("{}");
		j.set("foo", "[1, 2, 3, 4]");
		j["foo"].remove(2);
		std::cout << j.serialize() << "\n";
	}
	catch(const std::exception& e)
	{
		std::cout << e.what() << "\n";
	}
}
Esempio n. 2
0
bool Katana::testSpeedSrv(std_srvs::Empty::Request &request, std_srvs::Empty::Response &response)
{
  testSpeed();
  return true;
}
void test_random()
{
	initGraphics(1024, 1024);
	Random rnd(time(NULL));
	//
	for (int i = 0; i < 200; i++)
		printf("mt: %u\n", rnd._next());

	SDL_WM_SetCaption("Testing MTRandom", NULL);

	grand = &rnd;

	testSpeed("unitDiscSample()s", genrandpair);

	testSpeed("SDL_ThreadID()s", threadid);

	double delayFactor = 1000.0;
	// test the random generator graphically:
	for (int i = 0; i < 30000; i++) {
		// generate new 1000 integer points:
		for (int j = 0; j < 1000; j++)
			int_buff[rnd.randint(0, 511)][rnd.randint(0, 511)]++;

		// generate new 1000 floatingpoint points:
		for (int j = 0; j < 1000; j++) {
			float x = rnd.randfloat()*512;
			float y = rnd.randfloat()*512;
			int x0 = (int) floor(x);
			int y0 = (int) floor(y);
			int x1 = (x0 + 1) % 512;
			int y1 = (y0 + 1) % 512;
			float p = x - x0;
			float q = y - y0;
			float_buff[y0][x0] += (1 - p) * (1 - q);
			float_buff[y0][x1] += (    p) * (1 - q);
			float_buff[y1][x0] += (1 - p) * (    q);
			float_buff[y1][x1] += (    p) * (    q);
		}

		// generate new 1000 circle points:
		for (int j = 0; j < 1000; j++) {
			double cx, cy;
			rnd.unitDiscSample(cx, cy);
			float x = float(cx * 256 + 256);
			float y = float(cy * 256 + 256);
			int x0 = (int) floor(x);
			int y0 = (int) floor(y);
			int x1 = (x0 + 1) % 512;
			int y1 = (y0 + 1) % 512;
			float p = x - x0;
			float q = y - y0;
			circle_buff[y0][x0] += (1 - p) * (1 - q);
			circle_buff[y0][x1] += (    p) * (1 - q);
			circle_buff[y1][x0] += (1 - p) * (    q);
			circle_buff[y1][x1] += (    p) * (    q);
		}

		// generate new 5000 normally-distributed points:
		for (int j = 0; j < 5000; j++) {
			double x = rnd.gaussian(256, 256.0/3.0);
			if (x < 0 || x >= 511) continue;
			double p = x - floor(x);
			int x0 = floor(x);
			norm_buff[x0] += (1 - p);
			norm_buff[x0 + 1] += p;
		}
		//
		displayCharts((i + 1) * 5000);
		displayVFB(vfb);
		SDL_Delay((int) delayFactor);
		delayFactor *= 0.9;
	}
	waitForUserExit();
	closeGraphics();
}