コード例 #1
0
ファイル: test.c プロジェクト: unwind/lzjb-stream
int main(int argc, char *argv[])
{
    size_t	i;

    printf("Testing lzjb-stream's size codec API ...\n");
    /* Hard-coded edge cases. */
    test_size(0);
    test_size(~(size_t) 0);
    /* A single walking 1-bit. */
    for(i = 1; i != 0; i <<= 1)
        test_size(i);
    for(i = 0; i < 1000000; ++i)
    {
        test_size(rand());
    }

    printf("Testing lzjb-stream's decompression API ...\n");
    test_decompress();

    printf("%zu/%zu tests passed\n", test_state.pass_count, test_state.count);

    printf("Testing performance ...\n");
    test_performance("performance-data.lzjb");

    printf("By the way, the stream itself is %zu bytes\n", sizeof (LZJBStream));

    return EXIT_SUCCESS;
}
コード例 #2
0
ファイル: test.c プロジェクト: kexianda/misc
int main() {
	int ret = 0;

	if(verify() != 0) {
		return 1;
	}
	
	test_performance();
	return ret;
}
コード例 #3
0
ファイル: main.c プロジェクト: EnjoyHacking/biginteger
int main(int argc, const char **argv)
{
	test_create();
	test_to_long_long();
	test_compare();
	test_add();
	test_subtract();
	test_increment();
	test_decrement();
	
	test_performance();

	printf("\nAll tests passed!\n");
	return EXIT_SUCCESS;
};
コード例 #4
0
ファイル: mlog_test.c プロジェクト: github188/grpc
int main(int argc, char** argv) {
  grpc_test_init(argc, argv);
  gpr_time_init();
  srand((unsigned)gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
  test_invalid_record_size();
  test_end_write_with_different_size();
  test_read_pending_record();
  test_read_beyond_pending_record();
  test_detached_while_reading();
  test_fill_log_no_fragmentation();
  test_fill_circular_log_no_fragmentation();
  test_fill_log_with_straddling_records();
  test_fill_circular_log_with_straddling_records();
  test_small_log();
  test_multiple_writers();
  test_multiple_writers_circular_log();
  test_performance();
  return 0;
}
コード例 #5
0
int
main (int argc, ACE_TCHAR *argv[])
{
  ACE_START_TEST (ACE_TEXT ("Handle_Set_Test"));

  int count = argc > 1
    ? ACE_OS::atoi (argv[1])
    : ACE_Handle_Set::MAXSIZE;
  size_t max_handles =
    argc > 2
    ? ACE_OS::atoi (argv[2])
    : ACE_Handle_Set::MAXSIZE;
  size_t max_iterations =
    argc > 3
    ? ACE_OS::atoi (argv[3])
    : ACE_MAX_ITERATIONS;

  test_duplicates (count);
  test_boundaries ();
  test_performance (max_handles,
                    max_iterations);
  ACE_END_TEST;
  return 0;
}
コード例 #6
0
ファイル: Timer_Queue_Test.cpp プロジェクト: CCJY/ACE
int
run_main (int argc, ACE_TCHAR *argv[])
{
  ACE_START_TEST (ACE_TEXT ("Timer_Queue_Test"));

  if (argc > 1)
    max_iterations = ACE_OS::atoi (argv[1]);

  // = Perform initializations.

  Timer_Queue_Stack *tq_stack = 0;

  // Add new Timer_Queue implementations here.  Note that these will
  // be executed in "reverse order".

  // Timer_Hash (Heap)
  ACE_NEW_RETURN (tq_stack,
                  Timer_Queue_Stack (new ACE_Timer_Hash_Heap,
                                     ACE_TEXT ("ACE_Timer_Hash (Heap)"),
                                     tq_stack),
                  -1);

  // Timer_Hash
  ACE_NEW_RETURN (tq_stack,
                  Timer_Queue_Stack (new ACE_Timer_Hash,
                                     ACE_TEXT ("ACE_Timer_Hash"),
                                     tq_stack),
                  -1);

  // Timer_stack
  ACE_NEW_RETURN (tq_stack,
                  Timer_Queue_Stack (new ACE_Timer_List,
                                     ACE_TEXT ("ACE_Timer_List"),
                                     tq_stack),
                  -1);

  // Timer_Wheel without preallocated memory
  ACE_NEW_RETURN (tq_stack,
                  Timer_Queue_Stack (new ACE_Timer_Wheel,
                                     ACE_TEXT ("ACE_Timer_Wheel (non-preallocated)"),
                                     tq_stack),
                  -1);

  // Timer_Wheel with preallocated memory.
  ACE_NEW_RETURN (tq_stack,
                  Timer_Queue_Stack (new ACE_Timer_Wheel (ACE_DEFAULT_TIMER_WHEEL_SIZE,
                                                          ACE_DEFAULT_TIMER_WHEEL_RESOLUTION,
                                                          max_iterations),
                                     ACE_TEXT ("ACE_Timer_Wheel (preallocated)"),
                                     tq_stack),
                  -1);
  // Timer_Heap without preallocated memory.
  ACE_NEW_RETURN (tq_stack,
                  Timer_Queue_Stack (new ACE_Timer_Heap,
                                     ACE_TEXT ("ACE_Timer_Heap (non-preallocated)"),
                                     tq_stack),
                  -1);

  // Timer_Heap with preallocate memory.
  ACE_NEW_RETURN (tq_stack,
                  Timer_Queue_Stack (new ACE_Timer_Heap (max_iterations, 1),
                                     ACE_TEXT ("ACE_Timer_Heap (preallocated)"),
                                     tq_stack),
                  -1);

  // Timer_Heap without preallocated memory, using high-res time.
  // @deprecated
  (void) ACE_High_Res_Timer::global_scale_factor ();

  ACE_Timer_Heap *tq_heap =
    new ACE_Timer_Heap;
  tq_heap->gettimeofday(&ACE_High_Res_Timer::gettimeofday_hr);
  ACE_NEW_RETURN (tq_stack,
                  Timer_Queue_Stack (tq_heap,
                                     ACE_TEXT ("ACE_Timer_Heap (high-res timer; deprecated version)"),
                                     tq_stack),
                  -1);

  // new (optimized) version
  typedef ACE_Timer_Heap_T<ACE_Event_Handler *,
                           ACE_Event_Handler_Handle_Timeout_Upcall,
                           ACE_SYNCH_RECURSIVE_MUTEX,
                           ACE_HR_Time_Policy>
          timer_heap_hr_type;
  ACE_NEW_RETURN (tq_stack,
                  Timer_Queue_Stack (new timer_heap_hr_type,
                                     ACE_TEXT ("ACE_Timer_Heap (high-res timer)"),
                                     tq_stack),
                  -1);


  // Create the Timer ID array
  ACE_NEW_RETURN (timer_ids,
                  long[max_iterations],
                  -1);

  Timer_Queue_Stack *tq_ptr = tq_stack;

  while (tq_ptr != 0)
    {
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("**** starting test of %s\n"),
                  tq_ptr->name_));
      test_interval_timer (tq_ptr->queue_);
      test_functionality (tq_ptr->queue_);
      test_performance (tq_ptr->queue_,
                        tq_ptr->name_);
      delete tq_ptr->queue_;
      Timer_Queue_Stack *temp = tq_ptr;
      tq_ptr = tq_ptr->next_;
      delete temp;
    }
  delete [] timer_ids;

  ACE_DEBUG
    ((LM_DEBUG,
      ACE_TEXT ("**** starting unique IDs test for ACE_Timer_Heap\n")));
  test_unique_timer_heap_ids ();

  ACE_END_TEST;
  return 0;
}
コード例 #7
0
ファイル: test_uctx.c プロジェクト: 4sp1r3/shadow
int main(int argc, char *argv[])
{
    test_working();
    test_performance();
    return 0;
}
コード例 #8
0
    inline test_statistic adjoint_performance(AdjointTask const& task, std::ostream& out_stream = fake_stream())
    {
        typedef typename AdjointTask::inner_type inner_type;
        typedef typename AdjointTask::tape_type tape_type;
        test_statistic result;
        result.size_ = task.size_;

        // Input values initialization.
        std::vector<inner_type> x_val = task.X_;
        std::vector<tape_type> X(x_val.begin(), x_val.end());
        out_str << "Input vector: " << X << "\n";

        // Output vector.
        std::vector<tape_type> Y;
        // Tape function.
        tfunc<inner_type> f;

        result.rec_ = test_performance(task.repeat_, [&X, &Y, &f, &task]()
        {
            // Declare the X vector as independent and start a tape recording.
            tape_start(X);
            // Output calculations.
            Y = task.func_(X);
            //Stop tape recording.
            f.tape_read(X, Y);
        });

        out_str << "Output vector: " << Y << "\n\n";

        out_str << "Ininial Forward(0) sweep...\n\n";
        result.init_ = test_performance(task.repeat_, [&f, &x_val]()
        {
            f.forward(0, x_val);
        });

        // Forward sweep calculations.
        std::vector<inner_type> dx = task.dx_;
        out_str << "Forward(1, dx) sweep for dx = " << dx << "..." << std::endl;
        std::vector<inner_type> forw = f.forward(1, dx, out_stream);
        out_str << "Forward sweep result: " << forw << "\n\n";

        result.forw_ = test_performance(task.repeat_, [&f, &dx]()
        {
            f.forward(1, dx);
        });

        // Reverse sweep calculations.
        std::vector<inner_type> w = task.w_;
        out_str << "Reverse(1, w) sweep for w = " << w << "..." << std::endl;
        std::vector<inner_type> rev = f.reverse(1, w);
        out_str << "Reverse sweep result: " << rev << "\n\n\n";

        result.rev_ = test_performance(task.repeat_, [&f, &w]()
        {
            f.reverse(1, w);
        });

        result.mem_ = f.Memory();

        return result;
    }
コード例 #9
0
ファイル: check_bvgraph.c プロジェクト: brainey421/libbvg
int main(int argc, char** argv)
{
    bvgraph g = {0};
    //const char* name = "libbvg/data/wb-cs.stanford";
    const char* name = argv[1];
    char* method = argv[2];
    int rval = 0;

    if (method == NULL) {
        print_help();
        return 0;
    }

    //load with offsets
    rval = bvgraph_load(&g, name, strlen(name), 1);
    if (rval != 0) {
        printf("Failed to load file %s\n", name);
        return (-1);
    }

    printf("Input file: %s\n", name);
    printf("nodes = %"PRId64"\n", g.n);
    printf("edges = %"PRId64"\n", g.m);

    if (strcmp(method, "random") == 0){
        load_all(name);
        if (argv[3] == NULL){
            printf("Need node number. Stop\n");
            return 1;
        }
        int num = atoi(argv[3]);
        random_test(g, num);
    }
    else if (strcmp(method, "head-tail") == 0){
        load_all(name);
        head_tail_first_test(g);
    }
    else if (strcmp(method, "all") == 0){
        load_all(name);
        print_all(g);
    }
    else if (strcmp(method, "perform") == 0){
        // test performance
        if (argv[3] == NULL){
            printf("Need node number. Stop\n");
            return 1;
        }
        int num = atoi(argv[3]);
        test_performance(g, num);
    }
    else if (strcmp(method, "iter") == 0){
        iteration(name);
    }
    else{
        print_help();
    }

    bvgraph_close(&g);

    return 0;
}
コード例 #10
0
int main(int argc, char *argv[]) {
    (void) argc; (void) argv;

	FILE* logfile;
	logfile = fopen(LOGFILE, "w");

    perf_measure perf_default = {"default measurement", 0, 0, LOGGING, logfile};
    perf_measure perf_program_creation = perf_default;
    perf_program_creation.name = "creation";
    perf_measure perf_program_execution = perf_default;
    perf_program_execution.name = "execution";
    perf_measurement_init();

    particle_vis_init();

    particle_array initial_arr;
    particle_array_create(&initial_arr);
    unsigned int N = 16;
    for(size_t i = 0;i<N;++i) {
        for(size_t j = 0;j<N;++j) {
            particle p;
            p.position[0] = (i+0.5f)/(float)N-0.5f; p.position[1] = 1; p.position[2] = (j+0.5f)/(float)N-0.5f;
            p.velocity[0] = 0; p.velocity[1] = 0; p.velocity[2] = 0;
            p.mass = 1;
            p.charge = 1;
            particle_array_add(&initial_arr, p);
        }
    }


    effect_desc effects;
    effect_desc_init(&effects);
    // construct effect array:
    //~ effect_desc_add_linear_accel(&effects,  0, -10, 0);
    //~ effect_desc_add_sphere_bounce(&effects, 0,  0,  0, 0.707, 0.8);
    //~ effect_desc_add_plane_bounce(&effects,  0,  1,  0, -1,    0.8);
    //~ effect_desc_add_plane_bounce(&effects,  0, -1,  0, -1,    0.8);
    //~ effect_desc_add_plane_bounce(&effects,  1,  0,  0, -1,    0.8);
    //~ effect_desc_add_plane_bounce(&effects, -1,  0,  0, -1,    0.8);
    //~ effect_desc_add_plane_bounce(&effects,  0,  0,  1, -1,    0.8);
    //~ effect_desc_add_plane_bounce(&effects,  0,  0, -1, -1,    0.8);
    //~ effect_desc_add_central_force(&effects, 1, 0, 1, -1);
    //~ effect_desc_add_central_force(&effects,-1, 0, 1, -1);
    //~ effect_desc_add_central_force(&effects, 1, 0,-1, -1);
    //~ effect_desc_add_central_force(&effects,-1, 0,-1, -1);
    //~ effect_desc_add_sphere_bounce(&effects,  1,  0,  1, 0.1, 0.9);
    //~ effect_desc_add_sphere_bounce(&effects,  1,  0, -1, 0.1, 0.9);
    //~ effect_desc_add_sphere_bounce(&effects, -1,  0,  1, 0.1, 0.9);
    //~ effect_desc_add_sphere_bounce(&effects, -1,  0, -1, 0.1, 0.9);
    effect_desc_add_central_force(&effects, 1, 0, 1, -1);
    effect_desc_add_sphere_bounce(&effects,  1,  0,  1, 0.1, 0.9);
    effect_desc_add_central_force(&effects,-1, 0, 1, -1);
    effect_desc_add_sphere_bounce(&effects, -1,  0,  1, 0.1, 0.9);
    effect_desc_add_central_force(&effects, 1, 0,-1, -1);
    effect_desc_add_sphere_bounce(&effects,  1,  0, -1, 0.1, 0.9);
    effect_desc_add_central_force(&effects,-1, 0,-1, -1);
    effect_desc_add_sphere_bounce(&effects, -1,  0, -1, 0.1, 0.9);



    effect_desc_add_newton_step (&effects);

    // create reference program:
    effect_program ref_program;
    effect_program_create_naive(&ref_program);
    effect_program_compile(&ref_program, &effects);

    // create program:

    perf_start_measurement(&perf_program_creation);

    effect_program test_program_0;
    effect_program test_program_1;
    effect_program test_program_2;
    effect_program test_program_3;
    effect_program jit_program_0;
    effect_program jit_program_1;
    effect_program jit_program_2;
    effect_program jit_program_3;

    effect_program_create_naive(&test_program_0);
    effect_program_create_c_optimze1(&test_program_1);
    effect_program_create_c_optimze2(&test_program_2);
    effect_program_create_jit(&jit_program_0, JIT_AVX4 | JIT_O0);
    effect_program_create_jit(&jit_program_1, JIT_AVX4 | JIT_O1);
    effect_program_create_jit(&jit_program_2, JIT_AVX4 | JIT_O2);
    effect_program_create_jit(&jit_program_3, JIT_AVX4 | JIT_O3);

    //~ test_effects_all(&test_program_3);
    //~ test_effects_all(&test_program_1);

    // compile
    effect_program_compile(&test_program_0, &effects);
    effect_program_compile(&test_program_1, &effects);
    effect_program_compile(&test_program_2, &effects);
    effect_program_compile(&test_program_3, &effects);
    effect_program_compile(&jit_program_0, &effects);
    effect_program_compile(&jit_program_1, &effects);
    effect_program_compile(&jit_program_2, &effects);
    effect_program_compile(&jit_program_3, &effects);

    perf_stop_measurement(&perf_program_creation);

    // execute
	perf_start_measurement(&perf_program_execution);

	test_performance(&test_program_0, &initial_arr);
	test_performance(&test_program_1, &initial_arr);
	test_performance(&test_program_2, &initial_arr);
	test_performance(&jit_program_0, &initial_arr);
	test_performance(&jit_program_1, &initial_arr);
	test_performance(&jit_program_2, &initial_arr);
	test_performance(&jit_program_3, &initial_arr);
    printf("\n");
    //verify(&test_program_1, &ref_program, &initial_arr);
	verify(&jit_program_2, &ref_program, &initial_arr);

    perf_stop_measurement(&perf_program_execution);

    // print mesurements
    //~ perf_print_measurement(&perf_program_creation);
    //~ perf_print_measurement(&perf_program_execution);
    // clean up:
    effect_desc_destroy(&effects);
    effect_program_destroy(&ref_program);
    effect_program_destroy(&test_program_0);
    effect_program_destroy(&test_program_1);
    particle_array_destroy(&initial_arr);
    particle_vis_deinit();
	fclose(logfile);
    return 0;
}
コード例 #11
0
ファイル: test_category.c プロジェクト: HPCKP/gridengine
/****** test_category/test() ***************************************************
*  NAME
*     test() -- executes one test including a performance test run
*
*  SYNOPSIS
*     int test(data_entry_t *test, char *result, int count) 
*
*  INPUTS
*     data_entry_t *test - one test setup
*     char *result       - expected category
*     int count          - test number
*
*  RESULT
*     int - 0 okay, 1 failed
*
*  NOTES
*     MT-NOTE: test() is MT safe 
*
*******************************************************************************/
static int test(data_entry_t *test, char *result, int count) 
{
   int ret = 0;
   lListElem *job_elem = NULL;
   lList *access_list = NULL;
   lList *project_list = NULL;
   lList *rqs_list = NULL;

   printf("\ntest %d:\n-------\n", test->test_nr);
   
   job_elem = test_create_job(test, 1);

   if (test->is_access_list == 1) {
      access_list = test_create_access();
   }
   if (test->project) {
      project_list = test_create_project(test->project);
   }
   if (test->rqs) {
      rqs_list = test_create_rqs();
   }

   if (job_elem != NULL) {
       dstring category_str = DSTRING_INIT;

       sge_build_job_category_dstring(&category_str, job_elem, access_list, project_list, NULL, rqs_list);

       printf("got     : <%s>\n", sge_dstring_get_string(&category_str)!=NULL?sge_dstring_get_string(&category_str):"<NULL>");

       if (result != NULL && sge_dstring_get_string(&category_str) != NULL) {
         if (strcmp(result, sge_dstring_get_string(&category_str)) == 0) {
         } else {
            ret = 1;
            printf("expected: <%s>\n", result!=NULL? result:"<NULL>");
         }
       } else if (result == NULL &&  sge_dstring_get_string(&category_str) == NULL) {
       } else {
         ret = 1;
         printf("expected: <%s>\n", result!=NULL? result:"<NULL>");
       }
       
       if (ret == 0) {
         int i;
         int max = 10000;
         printf(" => category outputs match\n");
         lFreeElem(&job_elem);
         for (i = 1; i <= 500; i*=6) {
            printf("test with %dx :", i);
            job_elem = test_create_job(test, i);
            if (job_elem != NULL) {
               double time = test_performance(job_elem, max, access_list, NULL, rqs_list); 
               if (time > 1) {
                  max /= 10;
               }
               lFreeElem(&job_elem);
            } else {
               printf("failed to create job\n");
               ret = 1;
               break;
            }
         }
       }
       else {
         printf(" => test failed\n");
       }
       
       sge_dstring_free(&category_str);
   }
   else {
      printf("failed to create job for test %d\n", count);
      ret = 1;
   }
   lFreeElem(&job_elem);
   lFreeList(&access_list);
   lFreeList(&project_list);
   lFreeList(&rqs_list);
   return ret;
}
コード例 #12
0
ファイル: performance_test.c プロジェクト: Abioy/kythe
int main(int argc, char **argv) {
  grpc_test_init(argc, argv);
  srand(gpr_now().tv_nsec);
  test_performance();
  return 0;
}