| 919 | } |
| 920 | |
| 921 | int |
| 922 | hs_longrun_main(int argc, char **argv) |
| 923 | { |
| 924 | hs_longrun_shared shared; |
| 925 | parse_args(argc, argv, shared.conf); |
| 926 | shared.conf["host"] = shared.conf.get_str("host", "localhost"); |
| 927 | shared.verbose = shared.conf.get_int("verbose", 1); |
| 928 | const int table_size = shared.conf.get_int("table_size", 10000); |
| 929 | for (int i = 0; i < table_size; ++i) { |
| 930 | std::auto_ptr<record_value> rec(new record_value()); |
| 931 | rec->key = to_stdstring(i); |
| 932 | shared.records.push_back_ptr(rec); |
| 933 | } |
| 934 | mysql_library_init(0, 0, 0); |
| 935 | const int duration = shared.conf.get_int("duration", 10); |
| 936 | const int num_hsinsert = shared.conf.get_int("num_hsinsert", 10); |
| 937 | const int num_hsdelete = shared.conf.get_int("num_hsdelete", 10); |
| 938 | const int num_hsupdate = shared.conf.get_int("num_hsupdate", 10); |
| 939 | const int num_hsread = shared.conf.get_int("num_hsread", 10); |
| 940 | const int num_myread = shared.conf.get_int("num_myread", 10); |
| 941 | const int num_mydelins = shared.conf.get_int("num_mydelins", 10); |
| 942 | int num_hsreadnolock = shared.conf.get_int("num_hsreadnolock", 10); |
| 943 | const bool always_filled = (num_hsinsert == 0 && num_hsdelete == 0); |
| 944 | if (!always_filled) { |
| 945 | num_hsreadnolock = 0; |
| 946 | } |
| 947 | hs_longrun_init_table(shared.conf, always_filled ? table_size : 0, |
| 948 | shared); |
| 949 | /* create worker threads */ |
| 950 | static const struct thrtmpl_type { |
| 951 | const char *type; char op; int num; int hs; int lock; |
| 952 | } thrtmpl[] = { |
| 953 | { "hsinsert", 'I', num_hsinsert, 1, 1 }, |
| 954 | { "hsdelete", 'D', num_hsdelete, 1, 1 }, |
| 955 | { "hsupdate", 'U', num_hsupdate, 1, 1 }, |
| 956 | { "hsread", 'R', num_hsread, 1, 1 }, |
| 957 | { "hsreadnolock", 'N', num_hsreadnolock, 1, 0 }, |
| 958 | { "myread", 'R', num_myread, 0, 1 }, |
| 959 | { "mydelins", 'T', num_mydelins, 0, 1 }, |
| 960 | }; |
| 961 | typedef auto_ptrcontainer< std::vector<hs_longrun_thread_base *> > thrs_type; |
| 962 | thrs_type thrs; |
| 963 | for (size_t i = 0; i < sizeof(thrtmpl)/sizeof(thrtmpl[0]); ++i) { |
| 964 | const thrtmpl_type& e = thrtmpl[i]; |
| 965 | for (int j = 0; j < e.num; ++j) { |
| 966 | int id = thrs.size(); |
| 967 | const hs_longrun_thread_hs::arg_type arg(id, e.type, e.op, e.lock, |
| 968 | shared); |
| 969 | std::auto_ptr<hs_longrun_thread_base> thr; |
| 970 | if (e.hs) { |
| 971 | thr.reset(new hs_longrun_thread_hs(arg)); |
| 972 | } else { |
| 973 | thr.reset(new hs_longrun_thread_my(arg)); |
| 974 | } |
| 975 | thrs.push_back_ptr(thr); |
| 976 | } |
| 977 | } |
| 978 | shared.num_threads = thrs.size(); |
no test coverage detected