~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/queues.c

MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
*/
50
50
 
51
51
int init_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
52
 
               pbool max_at_top, int (*compare) (void *, uchar *, uchar *),
 
52
               bool max_at_top, int (*compare) (void *, uchar *, uchar *),
53
53
               void *first_cmp_arg)
54
54
{
55
55
  DBUG_ENTER("init_queue");
92
92
*/
93
93
 
94
94
int init_queue_ex(QUEUE *queue, uint max_elements, uint offset_to_key,
95
 
               pbool max_at_top, int (*compare) (void *, uchar *, uchar *),
 
95
               bool max_at_top, int (*compare) (void *, uchar *, uchar *),
96
96
               void *first_cmp_arg, uint auto_extent)
97
97
{
98
98
  int ret;
129
129
*/
130
130
 
131
131
int reinit_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
132
 
                 pbool max_at_top, int (*compare) (void *, uchar *, uchar *),
 
132
                 bool max_at_top, int (*compare) (void *, uchar *, uchar *),
133
133
                 void *first_cmp_arg)
134
134
{
135
135
  DBUG_ENTER("reinit_queue");
276
276
{
277
277
  uchar *element;
278
278
  uint elements,half_queue,offset_to_key, next_index;
279
 
  my_bool first= TRUE;
 
279
  bool first= true;
280
280
  uint start_idx= idx;
281
281
 
282
282
  offset_to_key=queue->offset_to_key;
302
302
    }
303
303
    queue->root[idx]=queue->root[next_index];
304
304
    idx=next_index;
305
 
    first= FALSE;
 
305
    first= false;
306
306
  }
307
307
 
308
308
  next_index= idx >> 1;
384
384
static uint tot_no_loops= 0;
385
385
static uint expected_part= 0;
386
386
static uint expected_num= 0;
387
 
static my_bool max_ind= 0;
388
 
static my_bool fix_used= 0;
389
 
static ulonglong start_time= 0;
 
387
static bool max_ind= 0;
 
388
static bool fix_used= 0;
 
389
static uint64_t start_time= 0;
390
390
 
391
 
static my_bool is_divisible_by(uint num, uint divisor)
 
391
static bool is_divisible_by(uint num, uint divisor)
392
392
{
393
393
  uint quotient= num / divisor;
394
394
  if (quotient * divisor == num)
395
 
    return TRUE;
396
 
  return FALSE;
 
395
    return true;
 
396
  return false;
397
397
}
398
398
 
399
399
void calculate_next()
495
495
  return 0;
496
496
}
497
497
 
498
 
my_bool check_num(uint num_part)
 
498
bool check_num(uint num_part)
499
499
{
500
500
  uint part= num_part >> 22;
501
501
  uint num= num_part & 0x3FFFFF;
502
502
  if (part == expected_part)
503
503
    if (num == expected_num)
504
 
      return FALSE;
 
504
      return false;
505
505
  printf("Expect part %u Expect num 0x%x got part %u num 0x%x max_ind %u fix_used %u \n",
506
506
          expected_part, expected_num, part, num, max_ind, fix_used);
507
 
  return TRUE;
 
507
  return true;
508
508
}
509
509
 
510
510
 
546
546
  }
547
547
}
548
548
 
549
 
my_bool perform_ins_del(QUEUE *queue, my_bool max_ind)
 
549
bool perform_ins_del(QUEUE *queue, bool max_ind)
550
550
{
551
551
  uint i= 0, no_loops= tot_no_loops, j= tot_no_parts;
552
552
  do
554
554
    uint num_part= *(uint*)queue_top(queue);
555
555
    uint part= num_part >> 22;
556
556
    if (check_num(num_part))
557
 
      return TRUE;
 
557
      return true;
558
558
    if (j++ >= no_loops)
559
559
    {
560
560
      calculate_end_next(part);
571
571
      queue_replaced(queue);
572
572
    }
573
573
  } while (++i < no_loops);
574
 
  return FALSE;
 
574
  return false;
575
575
}
576
576
 
577
 
my_bool do_test(uint no_parts, uint l_max_ind, my_bool l_fix_used)
 
577
bool do_test(uint no_parts, uint l_max_ind, bool l_fix_used)
578
578
{
579
579
  QUEUE queue;
580
 
  my_bool result;
 
580
  bool result;
581
581
  max_ind= l_max_ind;
582
582
  fix_used= l_fix_used;
583
583
  init_queue(&queue, no_parts, 0, max_ind, test_compare, NULL);
589
589
  if (result)
590
590
  {
591
591
    printf("Error\n");
592
 
    return TRUE;
 
592
    return true;
593
593
  }
594
 
  return FALSE;
 
594
  return false;
595
595
}
596
596
 
597
597
static void start_measurement()
601
601
 
602
602
static void stop_measurement()
603
603
{
604
 
  ulonglong stop_time= my_getsystime();
 
604
  uint64_t stop_time= my_getsystime();
605
605
  uint time_in_micros;
606
606
  stop_time-= start_time;
607
607
  stop_time/= 10; /* Convert to microseconds */
614
614
  QUEUE queue_real;
615
615
  QUEUE *queue= &queue_real;
616
616
  uint i, add;
617
 
  fix_used= TRUE;
618
 
  max_ind= FALSE;
 
617
  fix_used= true;
 
618
  max_ind= false;
619
619
  tot_no_parts= 1024;
620
620
  init_queue(queue, tot_no_parts, 0, max_ind, test_compare, NULL);
621
621
  /*
634
634
    }
635
635
    stop_measurement();
636
636
 
637
 
    fix_used= FALSE;
 
637
    fix_used= false;
638
638
    printf("Start benchmark queue_insert\n");
639
639
    start_measurement();
640
640
    for (i= 0; i < 128; i++)