Beispiel #1
0
int main(int argc, char const *argv[])
{

  if(DO_PRINT)
    printf("RANDOM ALLOCATION USAGE TEST\n\n");
	if(DO_PRINT)
    printf("STARTING...\n");

	struct parameters p;

	p.description = malloc(500);
	sprintf(p.description,"");

  p.deallocate_after_fail = true;
	p.dealloc_falldown = 0.8;
	p.max_allocs = 120;

	struct parameters p1, p2, p3;
	p1 = p2 = p3 = p;

  /*add_to_description("SMALL CHUNKS", &p1);
  run_all_benchmarks(32, p1);*/
  add_to_description("MEDIUM CHUNKS", &p2);
  run_all_benchmarks(128, p2);
	add_to_description("BIG CHUNKS", &p3);
  run_all_benchmarks(512, p3);

	print_results();

  return 0;

}
Beispiel #2
0
int main(int argc, char **argv) {
  thread_args *client_args = malloc(sizeof(thread_args));
  thread_args *server_args = malloc(sizeof(thread_args));
  int msg_size = -1;
  char *read_strategy = NULL;
  char *socket_type = NULL;
  size_t i;
  const test_strategy *strategy = NULL;
  int error = 0;

  gpr_cmdline *cmdline =
      gpr_cmdline_create("low_level_ping_pong network benchmarking tool");

  gpr_cmdline_add_int(cmdline, "msg_size", "Size of sent messages", &msg_size);
  gpr_cmdline_add_string(cmdline, "read_strategy", read_strategy_usage,
                         &read_strategy);
  gpr_cmdline_add_string(cmdline, "socket_type", socket_type_usage,
                         &socket_type);

  gpr_cmdline_parse(cmdline, argc, argv);

  if (msg_size == -1) {
    msg_size = 50;
  }

  if (read_strategy == NULL) {
    gpr_log(GPR_INFO, "No strategy specified, running all benchmarks");
    return run_all_benchmarks((size_t)msg_size);
  }

  if (socket_type == NULL) {
    socket_type = "tcp";
  }
  if (msg_size <= 0) {
    fprintf(stderr, "msg_size must be > 0\n");
    print_usage(argv[0]);
    return -1;
  }

  for (i = 0; i < GPR_ARRAY_SIZE(test_strategies); ++i) {
    if (strcmp(test_strategies[i].name, read_strategy) == 0) {
      strategy = &test_strategies[i];
    }
  }
  if (strategy == NULL) {
    fprintf(stderr, "Invalid read strategy %s\n", read_strategy);
    return -1;
  }

  client_args->read_bytes = strategy->read_strategy;
  client_args->write_bytes = blocking_write_bytes;
  client_args->setup = strategy->setup;
  client_args->msg_size = (size_t)msg_size;
  client_args->strategy_name = read_strategy;
  server_args->read_bytes = strategy->read_strategy;
  server_args->write_bytes = blocking_write_bytes;
  server_args->setup = strategy->setup;
  server_args->msg_size = (size_t)msg_size;
  server_args->strategy_name = read_strategy;

  error = run_benchmark(socket_type, client_args, server_args);

  gpr_cmdline_destroy(cmdline);
  return error;
}