Пример #1
0
void display (void) 
{
    glClearStencil(0); //clear the stencil buffer
    glClearDepth(1.0f);
    glClearColor (0.0,0.0,0.0,1);
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | 
GL_STENCIL_BUFFER_BIT); //clear the buffers
    glLoadIdentity();
    glTranslatef(0, 0, -10);
//start
    glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); //disable the color mask
    glDepthMask(GL_FALSE); //disable the depth mask
    glEnable(GL_STENCIL_TEST); //enable the stencil testing
    glStencilFunc(GL_ALWAYS, 1, 0xFFFFFFFF);
    glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); //set the stencil buffer to replace our next lot of data
    bench(); //set the data plane to be replaced
    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); //enable the color mask
    glDepthMask(GL_TRUE); //enable the depth mask
    glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF);
    glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); //set the stencil buffer to keep our next lot of data
    glDisable(GL_DEPTH_TEST); //disable depth testing of the reflection
    glPushMatrix();
    glScalef(1.0f, -1.0f, 1.0f); //flip the reflection vertically

    glTranslatef(0,2,0); //translate the reflection onto the drawing plane
    glRotatef(angle,0,1,0); //rotate the reflection
    square(); //draw the square as our reflection
    glPopMatrix();
    glEnable(GL_DEPTH_TEST); //enable the depth testing
    glDisable(GL_STENCIL_TEST); //disable the stencil testing

//end
    glEnable(GL_BLEND); //enable alpha blending
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //set the blending function
    
    bench(); //draw our bench
    glDisable(GL_BLEND); //disable alpha blending
    glRotatef(angle,0,1,0); //rotate our square
    square(); //draw our square
    glutSwapBuffers();
    angle++;
}
Пример #2
0
int main()
{
    int numBenchmarks = 5;
    if (runvector) numBenchmarks++;
#ifdef BENCHMARK_VALARRAY
    numBenchmarks++;
#endif
#ifdef FORTRAN_90
    numBenchmarks++;
#endif

    BenchmarkExt<int> bench("loop36: $x = exp($e)", numBenchmarks);

    bench.setNumParameters(numSizes);

    Array<int,1> parameters(numSizes);
    Array<long,1> iters(numSizes);
    Array<double,1> flops(numSizes);

    parameters=pow(pow(2.,0.25),tensor::i)+tensor::i;
    flops = 1 * parameters;
    iters = 100000000L / flops;
    iters = where(iters<2, 2, iters);
    cout << iters << endl;
    
    bench.setParameterVector(parameters);
    bench.setIterations(iters);
    bench.setOpsPerIteration(flops);
    bench.setDependentVariable("flops");
    bench.beginBenchmarking();



    ArrayVersion(bench);
    ArrayVersion_unaligned(bench);
    ArrayVersion_misaligned(bench);
    ArrayVersion_index(bench);
    //doTinyVectorVersion(bench);
    F77Version(bench);
#ifdef FORTRAN_90
    F90Version(bench);
#endif
#ifdef BENCHMARK_VALARRAY
    ValarrayVersion(bench);
#endif

    if(runvector)
      VectorVersion(bench);

    bench.endBenchmarking();

    bench.saveMatlabGraph("loop36.m");
    return 0;
}
Пример #3
0
int main()
{
    int numBenchmarks = 5;
#ifndef BENCHMARK_VALARRAY
    numBenchmarks--;   // No  valarray
#endif
#ifndef FORTRAN_90
    numBenchmarks--;   // No fortran 90
#endif

    BenchmarkExt<int> bench("loop18: $x=(u+$a)*(v+$b)", numBenchmarks);

    const int numSizes = 23;
    bench.setNumParameters(numSizes);
    bench.setRateDescription("Mflops/s");

    Vector<int> parameters(numSizes);
    Vector<long> iters(numSizes);
    Vector<double> flops(numSizes);

    for (int i=0; i < numSizes; ++i)
    {
        parameters[i] = (int)pow(10.0, (i+1)/4.0);
        iters[i] = 10000000L / parameters[i];
        if (iters[i] < 2)
            iters[i] = 2;
        flops[i] = 3 * parameters[i];
    }

    bench.setParameterVector(parameters);
    bench.setIterations(iters);
    bench.setFlopsPerIteration(flops);

    bench.beginBenchmarking();

    double u = 0.39123982498157938742;
    double v = 0.39123982498157938742;

    VectorVersion(bench, u, v);
    ArrayVersion(bench, u, v);
    F77Version(bench, u, v);
#ifdef FORTRAN_90
    F90Version(bench, u, v);
#endif
#ifdef BENCHMARK_VALARRAY
    ValarrayVersion(bench, u, v);
#endif

    bench.endBenchmarking();

    bench.saveMatlabGraph("loop18.m");

    return 0;
}
	Stat operator()(const std::string& name, unsigned iterations, TF&& functor, TArgs&&... args)
	{
		Stat stat;
		PrintfLogger logger;
		if(m_startlog_enabled)
			logger.logStart(name, iterations);
		stat = bench(iterations, functor,  std::forward(args)...);
		if(m_endlog_enabled)
			logger.logEnd(name, iterations, stat);
		return stat;
	}
Пример #5
0
int main()
{
    int numBenchmarks = 6;
#ifndef BENCHMARK_VALARRAY
		numBenchmarks--;   // No  valarray
#endif
#ifndef FORTRAN_90
		numBenchmarks--;   // No fortran 90
#endif

    BenchmarkExt<int> bench("DAXPY Benchmark", numBenchmarks);

    const int numSizes = 19;
    bench.setNumParameters(numSizes);

    Vector<int> parameters(numSizes);
    Vector<long> iters(numSizes);
    Vector<double> flops(numSizes);

    for (int i=0; i < numSizes; ++i)
    {
        parameters(i) = static_cast<int>(pow(10.0, 0.25*(i+1)));
        iters(i) = 50000000L / parameters(i);
        if (iters(i) < 2)
            iters(i) = 2;
        flops(i) = 2 * parameters(i) * 2;
    }

    bench.setParameterVector(parameters);
    bench.setIterations(iters);
    bench.setOpsPerIteration(flops);

    bench.beginBenchmarking();

    float a = .398498293819823;

    daxpyVectorVersion(bench, a, -a);
    daxpyArrayVersion(bench, a);
    daxpyF77Version(bench, a);
    daxpyBLASVersion(bench, a);
#ifdef FORTRAN_90
    daxpyF90Version(bench, a);
#endif
#ifdef BENCHMARK_VALARRAY
    daxpyValarrayVersion(bench, a);
#endif

    bench.endBenchmarking();

    bench.saveMatlabGraph("daxpy.m");

    return 0;
}
Пример #6
0
  /// Handler for messages coming in from the browser via postMessage().  The
  /// @a var_message can contain anything: a JSON string; a string that encodes
  /// method names and arguments; etc.  For example, you could use
  /// JSON.stringify in the browser to create a message that contains a method
  /// name and some parameters, something like this:
  ///   var json_message = JSON.stringify({ "myMethod" : "3.14159" });
  ///   nacl_module.postMessage(json_message);
  /// On receipt of this message in @a var_message, you could parse the JSON to
  /// retrieve the method name, match it to a function call, and then call it
  /// with the parameter.
  /// @param[in] var_message The message posted by the browser.
  virtual void HandleMessage(const pp::Var& var_message) {
    if (!var_message.is_string())
        return;

    std::string message = var_message.AsString();
    pp::Var var_reply;
    if (message == kBenchString) {
      bench();
      var_reply = pp::Var(kReplyString);
      PostMessage(var_reply);
    }
  }
Пример #7
0
gint
main (gint    argc,
      gchar **argv)
{
  GeglBuffer *buffer;

  gegl_init (&argc, &argv);

  buffer = test_buffer (1024, 1024, babl_format ("RGB float"));
  bench ("saturation (RGB)", buffer, &saturation);
  g_object_unref (buffer);

  buffer = test_buffer (1024, 1024, babl_format ("RGBA float"));
  bench ("saturation (RGBA)", buffer, &saturation);
  g_object_unref (buffer);

  buffer = test_buffer (1024, 1024, babl_format ("CIE Lab float"));
  bench ("saturation (CIE Lab)", buffer, &saturation);
  g_object_unref (buffer);

  buffer = test_buffer (1024, 1024, babl_format ("CIE Lab alpha float"));
  bench ("saturation (CIE Lab alpha)", buffer, &saturation);
  g_object_unref (buffer);

  buffer = test_buffer (1024, 1024, babl_format ("CIE LCH(ab) float"));
  bench ("saturation (CIE LCH(ab))", buffer, &saturation);
  g_object_unref (buffer);

  buffer = test_buffer (1024, 1024, babl_format ("CIE LCH(ab) alpha float"));
  bench ("saturation (CIE LCH(ab) alpha)", buffer, &saturation);
  g_object_unref (buffer);

  gegl_exit ();
  return 0;
}
Пример #8
0
gint
main (gint    argc,
      gchar **argv)
{
  GeglBuffer *buffer;

  gegl_init(&argc, &argv);

  buffer = test_buffer(1024, 1024, babl_format("RGB float"));
  bench("gaussian-blur (RGB)", buffer, &blur);
  g_object_unref (buffer);

  buffer = test_buffer(1024, 1024, babl_format("RaGaBaA float"));
  bench("gaussian-blur (RaGaBaA)", buffer, &blur);
  g_object_unref (buffer);

  buffer = test_buffer(1024, 1024, babl_format("RGBA float"));
  bench("gaussian-blur (RGBA)", buffer, &blur);
  g_object_unref (buffer);

  buffer = test_buffer(1024, 1024, babl_format("Y float"));
  bench("gaussian-blur (Y)", buffer, &blur);
  g_object_unref (buffer);

  buffer = test_buffer(1024, 1024, babl_format("YaA float"));
  bench("gaussian-blur (YaA)", buffer, &blur);
  g_object_unref (buffer);

  buffer = test_buffer(1024, 1024, babl_format("YA float"));
  bench("gaussian-blur (YA)", buffer, &blur);
  g_object_unref (buffer);

  gegl_exit ();
  return 0;
}
Пример #9
0
int main()
{

#ifdef BENCHMARK_VALARRAY
    int numBenchmarks = 6;
#else
    int numBenchmarks = 5;
#endif

    BenchmarkExt<int> bench("DAXPY Benchmark", numBenchmarks);

    const int numSizes = 19;
    bench.setNumParameters(numSizes);
    bench.setRateDescription("Mflops/s");

    Vector<int> parameters(numSizes);
    Vector<long> iters(numSizes);
    Vector<double> flops(numSizes);

    for (int i=0; i < numSizes; ++i)
    {
        parameters[i] = pow(10.0, (i+1)/4.0);
        iters[i] = 50000000L / parameters[i];
        if (iters[i] < 2)
            iters[i] = 2;
        flops[i] = 2 * parameters[i] * 2;
    }

    bench.setParameterVector(parameters);
    bench.setIterations(iters);
    bench.setOpsPerIteration(flops);

    bench.beginBenchmarking();

    float a = .398498293819823;

    daxpyVectorVersion(bench, a, -a);
    daxpyArrayVersion(bench, a);
    daxpyF77Version(bench, a);
    daxpyBLASVersion(bench, a);
    daxpyF90Version(bench, a);

#ifdef BENCHMARK_VALARRAY
    daxpyValarrayVersion(bench, a);
#endif

    bench.endBenchmarking();

    bench.saveMatlabGraph("daxpy2.m");

    return 0;
}
Пример #10
0
int main()
{
    BenchmarkExt<int> bench("Array expression", 2);

    bench.beginBenchmarking();
    blitzVersion(bench);
    CVersion(bench);
    bench.endBenchmarking();

    bench.saveMatlabGraph("arrexpr1.m");

    return 0;
}
Пример #11
0
int main(int argc, char * argv[]) 
{
    int     i ;
    int     from, to, step ;
    int     count ;

    if (argc<2) {
        printf("usage:\n") ;
        printf("%s <n>\n", argv[0]) ;
        printf("\tif n=1 the output is verbose for one attempt\n") ;
        printf("\tif n>1 the output reads:\n") ;
        printf("\t# of elements | method1 | method2 | ...\n") ;
        printf("\n") ;
        printf("%s <from> <to> <step>\n", argv[0]) ;
        printf("\twill loop over the number of elements in input\n") ;
        printf("\n") ;
        return 0 ;
    }

    if (argc==2) {
        count = atoi(argv[1]) ;
        if (count==1) {
            bench(1, BIG_NUM) ;
        } else {
            for (i=0 ; i<atoi(argv[1]) ; i++) {
                bench(0, BIG_NUM) ;
            }
        }
    } else if (argc==4) {
        from = atoi(argv[1]) ;
        to   = atoi(argv[2]) ;
        step = atoi(argv[3]) ;
        for (count=from ; count<=to ; count+=step) {
            bench(0, count) ;
        }
    }

    return 0 ;
}
Пример #12
0
int main(int argc, char** argv) {
    int it = 1000000;

    if (argc != 3 && argc != 4) {
        fprintf(stderr, "usage: %s <regex to benchmark> <sample string> "
                        "[<iterations=%d>]\n", argv[0], it);
        return 1;
    }

    if (argc == 4) it = atoi(argv[3]);

    return bench(argv[1], argv[2], it);
}
Пример #13
0
int main()
{
    int numBenchmarks = 10;
#ifndef FORTRAN_90
		numBenchmarks--;   // No fortran 90
#endif

    BenchmarkExt<int> bench("Array stencil", numBenchmarks);

    const int numSizes = 28;

    bench.setNumParameters(numSizes);
    bench.setRateDescription("Mflops/s");

    Vector<int> parameters(numSizes);
    Vector<long> iters(numSizes);
    Vector<double> flops(numSizes);

    for (int i=0; i < numSizes; ++i)
    {
        parameters[i] = (i+1) * 8;
        iters[i] = 32*8*8*8/(i+1)/(i+1)/(i+1)/4;
        if (iters[i] < 2)
            iters[i] = 2;
        int npoints = parameters[i] - 2;
        flops[i] = npoints * npoints * npoints * 7 * 2;
    }

    bench.setParameterVector(parameters);
    bench.setIterations(iters);
    bench.setFlopsPerIteration(flops);

    bench.beginBenchmarking();
#ifdef FORTRAN_90
    stencilFortran90Version(bench);
#endif
    stencilBlitzVersion(bench);
    stencilBlitzStencilVersion(bench);
    stencilBlitzExpressionVersion(bench);
    stencilBlitzProductVersion(bench);
    stencilBlitzProductVersion2(bench);
    stencilBlitzProductVersion3(bench);
    stencilBlitzIndexVersion(bench);
    stencilFortran77Version(bench);
    stencilFortran77VersionTiled(bench);
    bench.endBenchmarking();

    bench.saveMatlabGraph("stencil.m","plot");

    return 0;
}
Пример #14
0
gint
main (gint    argc,
      gchar **argv)
{
  GeglBuffer *buffer;

  gegl_init (&argc, &argv);

  buffer = test_buffer (2048, 1024, babl_format ("RGBA float"));

  bench("bcontrast", buffer, &blur);

  return 0;
}
Пример #15
0
int main(int argc, char *[])
{
    bench();

    /*
    	this generates an optimized code using vinsertf128 without vzeroupper
    	under /arch:AVX option .
    	Therefore, second bench() is slow.
    */
    float x = (float)argc;
    for (int i = 0; i < 8; i++) {
        a[i] = x;
    }
#ifdef USE_XBYAK
    if (argc == 1) {
        puts("not call vzeroupper");
    } else {
        puts("call vzeroupper");
        call_vzeroupper();
    }
#endif

    bench();
}
Пример #16
0
int main(int argc, const char** argv) {
	if(argc != 5) {
		std::cout << "usage : <problem_size> <input_file> <input_max_score> <output_file>" << std::endl;
		return EXIT_FAILURE;
	}


	Benchmark<1> bench(argv[4]);

	std::vector<const char*> population = {"10", "25", "50", "100", "1000"};
	std::vector<const char*> generation = {"10", "25", "50", "100", "1000"};
	std::vector<const char*> mutation = {"0.0", "0.3", "0.6", "1.0"};
#define ARGS_NUMBER 9

	const char* bench_argv[ARGS_NUMBER];
	bench_argv[0] = argv[0];
	bench_argv[1] = argv[1];
	bench_argv[2] = argv[2];
	bench_argv[3] = "-population";
	bench_argv[5] = "-generation";
	bench_argv[7] = "-mutation-rate";

	for(unsigned int  population_index = 0;  population_index <  population.size();  population_index++) {
		bench_argv[4] =  population[population_index];

		for(unsigned int generation_index = 0; generation_index < generation.size(); generation_index++) {
			bench_argv[6] = generation[generation_index];

			for(unsigned int mutation_index = 0; mutation_index < mutation.size(); mutation_index++) {
				bench_argv[8] = mutation[mutation_index];

				std::string name(bench_argv[4]);
				name += "_";
				name += bench_argv[6];
				name += "_";
				name += bench_argv[8];

				bench.execute<GeneticAlgorithm, GeneticAlgorithmProgramOption>(ARGS_NUMBER, bench_argv, argv[3], name);
			}
		}


	}

	bench.save();

	return EXIT_SUCCESS;
}
Пример #17
0
int
main(int argc, char** argv)
{
	uint32_t block_size   = 512;
	uint32_t sample_count = (1 << 19);

	for (int i = 1; i < argc; ++i) {
		if (!strcmp(argv[i], "--version")) {
			print_version();
			return 0;
		} else if (!strcmp(argv[i], "--help")) {
			print_usage();
			return 0;
		} else if (!strcmp(argv[i], "-f")) {
			full_output = true;
		} else if (!strcmp(argv[i], "-n") && (i + 1 < argc)) {
			sample_count = atoi(argv[++i]);
		} else if (!strcmp(argv[i], "-b") && (i + 1 < argc)) {
			block_size = atoi(argv[++i]);
		} else {
			print_usage();
			return 1;
		}
	}

	LilvWorld* world = lilv_world_new();
	lilv_world_load_all(world);

	atom_AtomPort   = lilv_new_uri(world, LV2_ATOM__AtomPort);
	atom_Sequence   = lilv_new_uri(world, LV2_ATOM__Sequence);
	lv2_AudioPort   = lilv_new_uri(world, LV2_CORE__AudioPort);
	lv2_CVPort      = lilv_new_uri(world, LV2_CORE__CVPort);
	lv2_ControlPort = lilv_new_uri(world, LV2_CORE__ControlPort);
	lv2_InputPort   = lilv_new_uri(world, LV2_CORE__InputPort);
	lv2_OutputPort  = lilv_new_uri(world, LV2_CORE__OutputPort);
	urid_map        = lilv_new_uri(world, LV2_URID__map);

	if (full_output) {
		printf("# Block Samples Time Plugin\n");
	}

	const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
	LILV_FOREACH(plugins, i, plugins) {
		bench(lilv_plugins_get(plugins, i), sample_count, block_size);
	}
Пример #18
0
int main()
{
	BenchmarkExt<int> bench("Haney Inductance Calculation", 3);

	bench.setRateDescription("Operations/s");

	bench.beginBenchmarking();

	HaneyCVersion(bench);
	HaneyFortranVersion(bench);
	HaneyBlitzVersion(bench);

	bench.endBenchmarking();

	bench.saveMatlabGraph("haney.m");

	return 0;
}
Пример #19
0
void    main    ( void )
{
	long    count;

	x[0]=1;
	y[0]=1;
	sx[0]=7;
	sy[0]=2;

	x[1]=10;
	y[1]=15;
	sx[1]=3;
	sy[1]=5;

	set_bmode();

	/*
	while( !kbhit() )
		move_it_up();
	*/

	count= bench();

	/*
	do
	{
		while( !( inp( 0x3da ) & 8 ) );
		bline( 128, 100, x1 + 128 , y1 + 100, 0 );
		x1= rand() % 128;
		y1= rand() % 100;
		c= rand() % 256;
		bline( 128, 100, x1 + 128 , y1 + 100, 15 );
	}
	while( !kbhit() );
	*/
	/*
	while( getch() != 27 );
	*/

	_asm    mov ax,3h
	_asm    int 10h

	printf( "bench: %ld == %ld / scan\n", count, count / ( 70 ) );
}
Пример #20
0
int main()
{
    if (dontActuallyRunBenchmark())
        return 0;

    int numBenchmarks = 2;

    BenchmarkExt<int> bench("loop1: $x=sqrt($y)", numBenchmarks);

    const int numSizes = 26;
    bench.setNumParameters(numSizes);
    //bench.setRateDescription("Mflops/s"); removed

    Vector<int> parameters(numSizes);
    Vector<long> iters(numSizes);
    Vector<double> flops(numSizes);

    for (int i=0; i < numSizes; ++i)
    {
      parameters(i) = (int)pow(10.0, (i+1)/4.0);
      iters[i] = 50000000L / parameters(i);
        if (iters(i) < 2)
	  iters(i) = 2;
        flops(i) = 1 * parameters(i);
    }

    bench.setParameterVector(parameters);
    bench.setIterations(iters);
    bench.setOpsPerIteration(flops);

    bench.beginBenchmarking();


    VectorVersion(bench);
    ArrayVersion(bench);

    bench.endBenchmarking();

    bench.saveMatlabGraph("loop1.m");

    return 0;
}
Пример #21
0
int tool_main(int argc, char** argv) {
    SkCommandLineFlags::Parse(argc, argv);
    SkAutoGraphics autoGraphics;

    // We share a single scratch bitmap among benches to reduce the profile noise from allocation.
    static const int kMaxArea = 209825221;  // tabl_mozilla is this big.
    SkAutoTMalloc<SkPMColor> scratch(kMaxArea);

    SkOSFile::Iter it(FLAGS_skps[0], ".skp");
    SkString filename;
    bool failed = false;
    while (it.next(&filename)) {
        if (SkCommandLineFlags::ShouldSkip(FLAGS_match, filename.c_str())) {
            continue;
        }

        const SkString path = SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str());

        SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path.c_str()));
        if (!stream) {
            SkDebugf("Could not read %s.\n", path.c_str());
            failed = true;
            continue;
        }
        SkAutoTUnref<SkPicture> src(SkPicture::CreateFromStream(stream));
        if (!src) {
            SkDebugf("Could not read %s as an SkPicture.\n", path.c_str());
            failed = true;
            continue;
        }

        if (src->width() * src->height() > kMaxArea) {
            SkDebugf("%s (%dx%d) is larger than hardcoded scratch bitmap (%dpx).\n",
                     path.c_str(), src->width(), src->height(), kMaxArea);
            failed = true;
            continue;
        }

        bench(scratch.get(), *src, filename.c_str());
    }
    return failed ? 1 : 0;
}
Пример #22
0
int main(int argc, char *argv[])
{
    if (argc != 5){
        fprintf(stderr, "Usage: %s test|bench arr_len loops nearest_len<50\n", argv[0]);
        return -1;
    }
    arr_len     = atoi(argv[2]);
    loops       = atoi(argv[3]);
    nearest_len = atoi(argv[4]);

    borRandInit(&r);

    if (strcmp(argv[1], "test") == 0){
        testCorrect();
    }else{
        bench();
    }

    return 0;
}
Пример #23
0
int main(int argc, char* argv[])
{
	{
	  // set max virtual memory to 2GB.
		size_t kOneGB = 1000 * 1024 * 1024;
		rlimit rl = { 2*kOneGB, 2*kOneGB };
		setrlimit(RLIMIT_AS, &rl);
	}

	printf("pid = %d\n", getpid());

	char name[256]="/home/lishuhuakai/";
	//strncpy(name, argv[0], 256);
	muduo::AsyncLogging log(::basename(name), kRollSize); // 好吧,构建一个新的logging对象
	log.start();
	g_asyncLog = &log;

	bool longLog = argc > 1;
	bench(longLog);
}
Пример #24
0
int main(int argc, const char** argv) {
	if(argc != 5) {
		std::cout << "usage : <problem_size> <input_file> <input_max_score> <output_file>" << std::endl;
		return EXIT_FAILURE;
	}


	Benchmark<1> bench(argv[4]);

	std::vector<const char*> neighborhood_orders = {/*"exchange,swap,insert", */"exchange,insert,swap"};
	std::vector<const char*> stop = {"time"/*, "update"*/};
#define ARGS_NUMBER 7

	const char* bench_argv[ARGS_NUMBER];
	bench_argv[0] = argv[0];
	bench_argv[1] = argv[1];
	bench_argv[2] = argv[2];
	bench_argv[3] = "-neighborhood-order";
	bench_argv[5] = "-stop";

	for(unsigned int  neighborhood_order_index = 0;  neighborhood_order_index <  neighborhood_orders.size();  neighborhood_order_index++) {
		bench_argv[4] =  neighborhood_orders[ neighborhood_order_index];

		for(unsigned int stop_index = 0; stop_index < stop.size(); stop_index++) {
			bench_argv[6] = stop[stop_index];

			std::string name(bench_argv[4]);
			name += "_";
			name += bench_argv[6];

			bench.execute<VNSSolver, VNSProgramOption>(ARGS_NUMBER, bench_argv, argv[3], name);
		}


	}

	bench.save();

	return EXIT_SUCCESS;
}
Пример #25
0
int main(int argc, const char * argv[])
{
	// Outputs data in gnuplot friendly .data format
	printf("#bytes    ns/elem\n");

	Int stopsPerFactor = 4; // For every power of 2, how many measurements do we do?
	Int minElemensFactor = 6;  // First measurement is 2^this number of elements.
	Int maxElemsFactor = 30; // Last measurement is 2^this number of elements. 30 == 16GB of memory
	//Int elemsPerMeasure = Int(1) << 28; // measure enough times to process this many elements (to get a good average)

	Int min = stopsPerFactor * minElemensFactor;
	Int max = stopsPerFactor * maxElemsFactor;

	for (Int ei=min; ei<=max; ++ei) {
		Int N = (Int)floor(pow(2.0, (double)ei / stopsPerFactor) + 0.5);
		//Int reps = elemsPerMeasure / N;
		Int reps = (Int)floor(1e9 / pow(N, 1.5) + 0.5);
		if (reps<1) reps = 1;
		double ans = bench(N, reps);
		printf("%llu   %f   # (N=%llu, reps=%llu) %llu/%llu\n", N*sizeof(Node), ans, N, reps, ei-min+1, max-min+1);
	}
}
Пример #26
0
/**
 * The program takes the following parameters
 *   - minimum skew (percentage)
 *   - maximum skew (percentage)
 *   - tree size (logarithmic)
 *   - Number of queries
 *   - Iterations
 *   - Trim
 *   - Random seed (optional)
 */
int main(int argc, char *argv[]) {
    // Parse program arguments
    SkewParams p(argc, argv);
    srand(p.random_seed);
    print_output_header(p);

    // Generate random numbers for the queries
    std::vector<int> queries;
    for (int q = 0; q < p.no_of_queries; q++) queries.push_back(rand());

    // Generate random numbers for the tree
    std::vector<int> values;
    for (int q = 0; q < p.tree_size; q++) values.push_back(rand());

    PredSearchTreeFactory tree_factory(MemoryLayout::DFS_EXPLICIT_INT);
    for (int skew = p.min_skew; skew <= p.max_skew; skew++) {
        // Build a new tree with the same values but different skew factor
        std::unique_ptr<PredSearchTree> t(tree_factory.createTree(values, skew));

        // Benchmark the predecessor searches
        bench(t.get(), queries, skew, p);
    }
}
Пример #27
0
int main(int argc, char *argv[])
{
    int opt=0;
    int options_index=0;
    char *tmp=NULL;

    if(argc==1)
    {
        usage();
        return 2;
    } 

    while((opt=getopt_long(argc,argv,"912Vfrt:p:c:?h",long_options,&options_index))!=EOF )
    {
        switch(opt)
        {
            case  0 : break;
            case 'f': force=1;break;
            case 'r': force_reload=1;break; 
            case '9': http10=0;break;
            case '1': http10=1;break;
            case '2': http10=2;break;
            case 'V': printf(PROGRAM_VERSION"\n");exit(0);
            case 't': benchtime=atoi(optarg);break;	     
            case 'p': 
                      /* proxy server parsing server:port */
                      tmp=strrchr(optarg,':');
                      proxyhost=optarg;
                      if(tmp==NULL)
                      {
                          break;
                      }
                      if(tmp==optarg)
                      {
                          fprintf(stderr,"Error in option --proxy %s: Missing hostname.\n",optarg);
                          return 2;
                      }
                      if(tmp==optarg+strlen(optarg)-1)
                      {
                          fprintf(stderr,"Error in option --proxy %s Port number is missing.\n",optarg);
                          return 2;
                      }
                      *tmp='\0';
                      proxyport=atoi(tmp+1);break;
            case ':':
            case 'h':
            case '?': usage();return 2;break;
            case 'c': clients=atoi(optarg);break;
        }
    }

    if(optind==argc) {
        fprintf(stderr,"webbench: Missing URL!\n");
        usage();
        return 2;
    }

    if(clients==0) clients=1;
    if(benchtime==0) benchtime=60;
    /* Copyright */
    fprintf(stderr,"Webbench - Simple Web Benchmark "PROGRAM_VERSION"\n"
            "Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.\n"
           );
    build_request(argv[optind]);
    /* print bench info */
    printf("\nBenchmarking: ");
    switch(method)
    {
        case METHOD_GET:
        default:
            printf("GET");break;
        case METHOD_OPTIONS:
            printf("OPTIONS");break;
        case METHOD_HEAD:
            printf("HEAD");break;
        case METHOD_TRACE:
            printf("TRACE");break;
    }
    printf(" %s",argv[optind]);
    switch(http10)
    {
        case 0: printf(" (using HTTP/0.9)");break;
        case 2: printf(" (using HTTP/1.1)");break;
    }
    printf("\n");
    if(clients==1) printf("1 client");
    else
        printf("%d clients",clients);

    printf(", running %d sec", benchtime);
    if(force) printf(", early socket close");
    if(proxyhost!=NULL) printf(", via proxy server %s:%d",proxyhost,proxyport);
    if(force_reload) printf(", forcing reload");
    printf(".\n");
    return bench();
}
Пример #28
0
/* main */
int main(int argc, char *argv[])
{
    int opt=0;
    int options_index=0;
    char *tmp=NULL;
    
    if(argc==1)
    {
        /* 参数个数不对打印信息 */
        usage();
        return 2;
    }
    
    /*
     1.单个字符,表示选项,
     2.单个字符后接一个冒号:表示该选项后必须跟一个参数。参数紧跟在选项后或者以空格隔开。该参数的指针赋给optarg。
     3 单个字符后跟两个冒号,表示该选项后可以有参数也可以没有参数。如果有参数,参数必须紧跟在选项后不能以空格隔开。该参数的指针赋给optarg。(这个特性是GNU的扩张)。
     */
    while((opt=getopt_long(argc,argv,"912Vfrt:p:c:?h",long_options,&options_index))!=EOF )
    {
        switch(opt)
        {
            case  0 : break;
            case 'f': force=1;break;
            case 'r': force_reload=1;break;
            case '9': http10=0;break;
            case '1': http10=1;break;
            case '2': http10=2;break;
            case 'V': printf(PROGRAM_VERSION"\n");exit(0);
            case 't': benchtime=atoi(optarg);break;
            case 'p':
                /* proxy server parsing server:port */
                tmp=strrchr(optarg,':');
                proxyhost=optarg;
                if(tmp==NULL)
                {
                    break;
                }
                if(tmp==optarg)
                {
                    fprintf(stderr,"Error in option --proxy %s: Missing hostname.\n",optarg);
                    return 2;
                }
                if(tmp==optarg+strlen(optarg)-1)
                {
                    fprintf(stderr,"Error in option --proxy %s Port number is missing.\n",optarg);
                    return 2;
                }
                *tmp='\0';
                proxyport=atoi(tmp+1);break;
            case ':':
            case 'h':
            case '?': usage();return 2;break;
            case 'c': clients=atoi(optarg);break;
        }
    }
    
    /* optind:表示下一次运行getopt时将读取数组第optind个。 */
    if(optind==argc) {
        /* 如果控制参数数的个数和总参数相同,则表示url没有输入 */
        fprintf(stderr,"webbench: Missing URL!\n");
		      usage();
		      return 2;
    }
    
    /* 参数设置纠错 */
    if(clients==0) clients=1;
    if(benchtime==0) benchtime=60;
    
    /* Copyright */
    fprintf(stderr,"Webbench - Simple Web Benchmark "PROGRAM_VERSION"\n"
            "Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.\n"
            );
    /* 创建请求,传入url */
    build_request(argv[optind]);
    
    /* print bench info */
    printf("\nBenchmarking: ");
    switch(method)
    {
        case METHOD_GET:
        default:
            printf("GET");break;
        case METHOD_OPTIONS:
            printf("OPTIONS");break;
        case METHOD_HEAD:
            printf("HEAD");break;
        case METHOD_TRACE:
            printf("TRACE");break;
    }
    printf(" %s",argv[optind]);
    switch(http10)
    {
        case 0: printf(" (using HTTP/0.9)");break;
        case 2: printf(" (using HTTP/1.1)");break;
    }
    printf("\n");
    if(clients==1) printf("1 client");
    else
        printf("%d clients",clients);
    
    printf(", running %d sec", benchtime);
    if(force) printf(", early socket close");
    if(proxyhost!=NULL) printf(", via proxy server %s:%d",proxyhost,proxyport);
    if(force_reload) printf(", forcing reload");
    printf(".\n");
    return bench();
}
Пример #29
0
int main(int argc, char** argv)
{
  { // normal case
    benchmark_t bench("malloc");
    rng_t rng;

    for (int i = 0; i < LOOP_CNT; ++i) {
      switch ((rng() >> 8) & 15) {
#define CASE(n) case n: delete new malloc_obj_t<n>; break
	CASE(0);
	CASE(1);
	CASE(2);
	CASE(3);
	CASE(4);
	CASE(5);
	CASE(6);
	CASE(7);
	CASE(8);
	CASE(9);
	CASE(10);
	CASE(11);
	CASE(12);
	CASE(13);
	CASE(14);
	CASE(15);
#undef CASE
      }
    }
  }

  picogc::gc gc;
  picogc::gc_scope gc_scope(&gc);
  { // GC case
    benchmark_t bench("picogc");
    picogc::scope scope;
    rng_t rng;

    for (int i = 0; i < LOOP_CNT / 100; ++i) {
      picogc::scope scope;
      for (int j = 0; j < 100; ++j) {
	switch ((rng() >> 8) & 15) {
#define CASE(n) case n: new (picogc::IS_ATOMIC) gc_obj_t<n>; break
	  CASE(0);
	  CASE(1);
	  CASE(2);
	  CASE(3);
	  CASE(4);
	  CASE(5);
	  CASE(6);
	  CASE(7);
	  CASE(8);
	  CASE(9);
	  CASE(10);
	  CASE(11);
	  CASE(12);
	  CASE(13);
	  CASE(14);
	  CASE(15);
#undef CASE
	}
      }
    }

    gc.trigger_gc();
  }

  return 0;
}
Пример #30
0
int main(void){
    //return launchNewton();
    //return launchNewtonOMP();
    return bench();
}