int main(int argc, char *argv[]) { SHARED_CONFIG _cfg, *cfg; int ch, cnt, runs; char *config_open, *working_dir; if ((progname = strrchr(argv[0], DIR_DELIM)) == NULL) progname = argv[0]; else ++progname; cfg = &_cfg; config_open = NULL; working_dir = NULL; runs = 1; /* * Explicitly initialize the shared configuration object before * parsing command line options. */ cfg->append_inserters = 1; cfg->conn = NULL; cfg->ftype = ROW; cfg->max_nops = 1000000; cfg->multiple_files = false; cfg->nkeys = 1000; cfg->reverse_scanners = 5; cfg->reverse_scan_ops = 10; cfg->thread_finish = false; cfg->vary_nops = false; while ((ch = __wt_getopt( progname, argc, argv, "C:Fk:h:l:n:R:r:t:vw:W:")) != EOF) switch (ch) { case 'C': /* wiredtiger_open config */ config_open = __wt_optarg; break; case 'F': /* multiple files */ cfg->multiple_files = true; break; case 'h': working_dir = __wt_optarg; break; case 'k': /* rows */ cfg->nkeys = (uint64_t)atol(__wt_optarg); break; case 'l': /* log */ if ((logfp = fopen(__wt_optarg, "w")) == NULL) { fprintf(stderr, "%s: %s\n", __wt_optarg, strerror(errno)); return (EXIT_FAILURE); } break; case 'n': /* operations */ cfg->max_nops = (uint64_t)atol(__wt_optarg); break; case 'R': cfg->reverse_scanners = (uint64_t)atol(__wt_optarg); break; case 'r': /* runs */ runs = atoi(__wt_optarg); break; case 't': switch (__wt_optarg[0]) { case 'f': cfg->ftype = FIX; break; case 'r': cfg->ftype = ROW; break; case 'v': cfg->ftype = VAR; break; default: return (usage()); } break; case 'v': /* vary operation count */ cfg->vary_nops = true; break; case 'w': cfg->reverse_scan_ops = (uint64_t)atol(__wt_optarg); break; case 'W': cfg->append_inserters = (uint64_t)atol(__wt_optarg); break; default: return (usage()); } argc -= __wt_optind; argv += __wt_optind; if (argc != 0) return (usage()); testutil_work_dir_from_path(home, 512, working_dir); if (cfg->vary_nops && !cfg->multiple_files) { fprintf(stderr, "Variable op counts only supported with multiple tables\n"); return (usage()); } /* Clean up on signal. */ (void)signal(SIGINT, onint); printf("%s: process %" PRIu64 "\n", progname, (uint64_t)getpid()); for (cnt = 1; runs == 0 || cnt <= runs; ++cnt) { printf( " %d: %" PRIu64 " reverse scanners, %" PRIu64 " writers\n", cnt, cfg->reverse_scanners, cfg->append_inserters); shutdown(); /* Clean up previous runs */ wt_connect(cfg, config_open); /* WiredTiger connection */ if (ops_start(cfg)) return (EXIT_FAILURE); wt_shutdown(cfg); /* WiredTiger shut down */ } return (0); }
int main(int argc, char *argv[]) { table_type ttype; int ch, cnt, ret, runs; char *working_dir; const char *config_open; if ((g.progname = strrchr(argv[0], DIR_DELIM)) == NULL) g.progname = argv[0]; else ++g.progname; config_open = NULL; ret = 0; working_dir = NULL; ttype = MIX; g.checkpoint_name = "WiredTigerCheckpoint"; if ((g.home = malloc(512)) == NULL) testutil_die(ENOMEM, "Unable to allocate memory"); g.nkeys = 10000; g.nops = 100000; g.ntables = 3; g.nworkers = 1; runs = 1; while ((ch = __wt_getopt( g.progname, argc, argv, "c:C:h:k:l:n:r:t:T:W:")) != EOF) switch (ch) { case 'c': g.checkpoint_name = __wt_optarg; break; case 'C': /* wiredtiger_open config */ config_open = __wt_optarg; break; case 'h': /* wiredtiger_open config */ working_dir = __wt_optarg; break; case 'k': /* rows */ g.nkeys = (u_int)atoi(__wt_optarg); break; case 'l': /* log */ if ((g.logfp = fopen(__wt_optarg, "w")) == NULL) { fprintf(stderr, "%s: %s\n", __wt_optarg, strerror(errno)); return (EXIT_FAILURE); } break; case 'n': /* operations */ g.nops = (u_int)atoi(__wt_optarg); break; case 'r': /* runs */ runs = atoi(__wt_optarg); break; case 't': switch (__wt_optarg[0]) { case 'c': ttype = COL; break; case 'l': ttype = LSM; break; case 'm': ttype = MIX; break; case 'r': ttype = ROW; break; default: return (usage()); } break; case 'T': g.ntables = atoi(__wt_optarg); break; case 'W': g.nworkers = atoi(__wt_optarg); break; default: return (usage()); } argc -= __wt_optind; if (argc != 0) return (usage()); /* Clean up on signal. */ (void)signal(SIGINT, onint); testutil_work_dir_from_path(g.home, 512, working_dir); printf("%s: process %" PRIu64 "\n", g.progname, (uint64_t)getpid()); for (cnt = 1; (runs == 0 || cnt <= runs) && g.status == 0; ++cnt) { printf(" %d: %u workers, %u tables\n", cnt, g.nworkers, g.ntables); (void)cleanup(); /* Clean up previous runs */ /* Setup a fresh set of cookies in the global array. */ if ((g.cookies = calloc( (size_t)(g.ntables), sizeof(COOKIE))) == NULL) { (void)log_print_err("No memory", ENOMEM, 1); break; } g.running = 1; if ((ret = wt_connect(config_open)) != 0) { (void)log_print_err("Connection failed", ret, 1); break; } if ((ret = start_checkpoints()) != 0) { (void)log_print_err("Start checkpoints failed", ret, 1); break; } if ((ret = start_workers(ttype)) != 0) { (void)log_print_err("Start workers failed", ret, 1); break; } g.running = 0; if ((ret = end_checkpoints()) != 0) { (void)log_print_err("Start workers failed", ret, 1); break; } free(g.cookies); g.cookies = NULL; if ((ret = wt_shutdown()) != 0) { (void)log_print_err("Start workers failed", ret, 1); break; } } if (g.logfp != NULL) (void)fclose(g.logfp); /* Ensure that cleanup is done on error. */ (void)wt_shutdown(); free(g.cookies); return (g.status); }
int main(int argc, char *argv[]) { u_int readers, writers; int ch, cnt, runs; char *config_open, *working_dir; if ((progname = strrchr(argv[0], DIR_DELIM)) == NULL) progname = argv[0]; else ++progname; config_open = NULL; working_dir = NULL; ftype = ROW; log_print = 0; multiple_files = 0; nkeys = 1000; max_nops = 10000; readers = 10; runs = 1; session_per_op = 0; vary_nops = 0; writers = 10; while ((ch = __wt_getopt( progname, argc, argv, "C:Fk:h:Ll:n:R:r:St:vW:")) != EOF) switch (ch) { case 'C': /* wiredtiger_open config */ config_open = __wt_optarg; break; case 'F': /* multiple files */ multiple_files = 1; break; case 'h': working_dir = __wt_optarg; break; case 'k': /* rows */ nkeys = (u_int)atoi(__wt_optarg); break; case 'L': /* log print per operation */ log_print = 1; break; case 'l': /* log */ if ((logfp = fopen(__wt_optarg, "w")) == NULL) { fprintf(stderr, "%s: %s\n", __wt_optarg, strerror(errno)); return (EXIT_FAILURE); } break; case 'n': /* operations */ max_nops = (u_int)atoi(__wt_optarg); break; case 'R': readers = (u_int)atoi(__wt_optarg); break; case 'r': /* runs */ runs = atoi(__wt_optarg); break; case 'S': /* new session per operation */ session_per_op = 1; break; case 't': switch (__wt_optarg[0]) { case 'f': ftype = FIX; break; case 'r': ftype = ROW; break; case 'v': ftype = VAR; break; default: return (usage()); } break; case 'v': /* vary operation count */ vary_nops = 1; break; case 'W': writers = (u_int)atoi(__wt_optarg); break; default: return (usage()); } argc -= __wt_optind; argv += __wt_optind; if (argc != 0) return (usage()); testutil_work_dir_from_path(home, 512, working_dir); if (vary_nops && !multiple_files) { fprintf(stderr, "Variable op counts only supported with multiple tables\n"); return (usage()); } /* Clean up on signal. */ (void)signal(SIGINT, onint); printf("%s: process %" PRIu64 "\n", progname, (uint64_t)getpid()); for (cnt = 1; runs == 0 || cnt <= runs; ++cnt) { printf( " %d: %u readers, %u writers\n", cnt, readers, writers); shutdown(); /* Clean up previous runs */ wt_connect(config_open); /* WiredTiger connection */ if (rw_start(readers, writers)) /* Loop operations */ return (EXIT_FAILURE); stats(); /* Statistics */ wt_shutdown(); /* WiredTiger shut down */ } return (0); }
int main(int argc, char *argv[]) { u_int readers, writers; int ch, cnt, runs; char *config_open; if ((progname = strrchr(argv[0], '/')) == NULL) progname = argv[0]; else ++progname; config_open = NULL; ftype = ROW; nkeys = 1000; nops = 10000; readers = 10; runs = 0; session_per_op = 0; writers = 10; while ((ch = getopt(argc, argv, "1C:k:l:n:R:r:St:W:")) != EOF) switch (ch) { case '1': /* One run */ runs = 1; break; case 'C': /* wiredtiger_open config */ config_open = optarg; break; case 'k': /* rows */ nkeys = (u_int)atoi(optarg); break; case 'l': /* log */ if ((logfp = fopen(optarg, "w")) == NULL) { fprintf(stderr, "%s: %s\n", optarg, strerror(errno)); return (EXIT_FAILURE); } break; case 'n': /* operations */ nops = (u_int)atoi(optarg); break; case 'R': readers = (u_int)atoi(optarg); break; case 'r': /* runs */ runs = atoi(optarg); break; case 'S': /* new session per operation */ session_per_op = 1; break; case 't': switch (optarg[0]) { case 'f': ftype = FIX; break; case 'r': ftype = ROW; break; case 'v': ftype = VAR; break; default: return (usage()); } break; case 'W': writers = (u_int)atoi(optarg); break; default: return (usage()); } argc -= optind; argv += optind; if (argc != 0) return (usage()); /* Clean up on signal. */ (void)signal(SIGINT, onint); printf("%s: process %" PRIu64 "\n", progname, (uint64_t)getpid()); for (cnt = 1; runs == 0 || cnt <= runs; ++cnt) { printf( " %d: %u readers, %u writers\n", cnt, readers, writers); shutdown(); /* Clean up previous runs */ wt_connect(config_open); /* WiredTiger connection */ load(); /* Load initial records */ /* Loop operations */ if (run(readers, writers)) return (EXIT_FAILURE); stats(); /* Statistics */ wt_shutdown(); /* WiredTiger shut down */ } return (0); }