| 608 | } |
| 609 | |
| 610 | static void benchmark_test() |
| 611 | { |
| 612 | QUEUE queue_real; |
| 613 | QUEUE *queue= &queue_real; |
| 614 | uint i, add; |
| 615 | fix_used= TRUE; |
| 616 | max_ind= FALSE; |
| 617 | tot_no_parts= 1024; |
| 618 | init_queue(queue, tot_no_parts, 0, max_ind, test_compare, NULL); |
| 619 | /* |
| 620 | First benchmark whether queue_fix is faster than using queue_insert |
| 621 | for sizes of 16 partitions. |
| 622 | */ |
| 623 | for (tot_no_parts= 2, add=2; tot_no_parts < 128; |
| 624 | tot_no_parts+= add, add++) |
| 625 | { |
| 626 | printf("Start benchmark queue_fix, tot_no_parts= %u \n", tot_no_parts); |
| 627 | start_measurement(); |
| 628 | for (i= 0; i < 128; i++) |
| 629 | { |
| 630 | perform_insert(queue); |
| 631 | queue_remove_all(queue); |
| 632 | } |
| 633 | stop_measurement(); |
| 634 | |
| 635 | fix_used= FALSE; |
| 636 | printf("Start benchmark queue_insert\n"); |
| 637 | start_measurement(); |
| 638 | for (i= 0; i < 128; i++) |
| 639 | { |
| 640 | perform_insert(queue); |
| 641 | queue_remove_all(queue); |
| 642 | } |
| 643 | stop_measurement(); |
| 644 | } |
| 645 | /* |
| 646 | Now benchmark insertion and deletion of 16400 elements. |
| 647 | Used in consecutive runs this shows whether the optimised _downheap |
| 648 | is faster than the standard implementation. |
| 649 | */ |
| 650 | printf("Start benchmarking _downheap \n"); |
| 651 | start_measurement(); |
| 652 | perform_insert(queue); |
| 653 | for (i= 0; i < 65536; i++) |
| 654 | { |
| 655 | uint num, part; |
| 656 | num= *(uint*)queue_top(queue); |
| 657 | num+= 16; |
| 658 | part= num >> 22; |
| 659 | num_array[part]= num; |
| 660 | queue_top(queue)= (uchar*)&num_array[part]; |
| 661 | queue_replaced(queue); |
| 662 | } |
| 663 | for (i= 0; i < 16; i++) |
| 664 | queue_remove(queue, (uint) 0); |
| 665 | queue_remove_all(queue); |
| 666 | stop_measurement(); |
| 667 | } |
no test coverage detected