| 655 | } |
| 656 | |
| 657 | int ObjBencher::seq_read_bench( |
| 658 | int seconds_to_run, int num_ops, int num_objects, |
| 659 | int concurrentios, int pid, bool no_verify) { |
| 660 | |
| 661 | lock_cond lc(&lock); |
| 662 | |
| 663 | if (concurrentios <= 0) |
| 664 | return -EINVAL; |
| 665 | |
| 666 | std::vector<string> name(concurrentios); |
| 667 | std::string newName; |
| 668 | unique_ptr<bufferlist> contents[concurrentios]; |
| 669 | int index[concurrentios]; |
| 670 | int errors = 0; |
| 671 | double total_latency = 0; |
| 672 | int r = 0; |
| 673 | std::vector<mono_time> start_times(concurrentios); |
| 674 | mono_clock::duration time_to_run = std::chrono::seconds(seconds_to_run); |
| 675 | std::chrono::duration<double> timePassed; |
| 676 | sanitize_object_contents(&data, data.op_size); //clean it up once; subsequent |
| 677 | //changes will be safe because string length should remain the same |
| 678 | |
| 679 | unsigned reads_per_object = 1; |
| 680 | if (data.op_size) |
| 681 | reads_per_object = data.object_size / data.op_size; |
| 682 | |
| 683 | r = completions_init(concurrentios); |
| 684 | if (r < 0) |
| 685 | return r; |
| 686 | |
| 687 | //set up initial reads |
| 688 | for (int i = 0; i < concurrentios; ++i) { |
| 689 | name[i] = generate_object_name_fast(i / reads_per_object, pid); |
| 690 | contents[i] = std::make_unique<bufferlist>(); |
| 691 | } |
| 692 | |
| 693 | std::unique_lock locker{lock}; |
| 694 | data.finished = 0; |
| 695 | data.start_time = mono_clock::now(); |
| 696 | locker.unlock(); |
| 697 | |
| 698 | pthread_t print_thread; |
| 699 | pthread_create(&print_thread, NULL, status_printer, (void *)this); |
| 700 | |
| 701 | mono_time finish_time = data.start_time + time_to_run; |
| 702 | //start initial reads |
| 703 | for (int i = 0; i < concurrentios; ++i) { |
| 704 | index[i] = i; |
| 705 | start_times[i] = mono_clock::now(); |
| 706 | create_completion(i, _aio_cb, (void *)&lc); |
| 707 | r = aio_read(name[i], i, contents[i].get(), data.op_size, |
| 708 | data.op_size * (i % reads_per_object)); |
| 709 | if (r < 0) { |
| 710 | cerr << "r = " << r << std::endl; |
| 711 | goto ERR; |
| 712 | } |
| 713 | locker.lock(); |
| 714 | ++data.started; |
nothing calls this directly
no test coverage detected