~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzleslap.cc

  • Committer: Brian Aker
  • Date: 2008-11-04 15:39:09 UTC
  • mfrom: (575.1.2 devel)
  • Revision ID: brian@tangent.org-20081104153909-c72hn65udxs1ccal
Merge of Monty's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
#include <ctype.h>
85
85
#include <string>
86
86
 
 
87
#include CMATH_H
 
88
 
 
89
#if defined(CMATH_NAMESPACE)
 
90
using namespace CMATH_NAMESPACE;
 
91
#endif
 
92
 
 
93
using namespace std;
 
94
 
87
95
#ifdef HAVE_SMEM
88
96
static char *shared_memory_base_name=0;
89
97
#endif
104
112
static char **defaults_argv;
105
113
 
106
114
char **primary_keys;
107
 
unsigned long long primary_keys_number_of;
 
115
uint64_t primary_keys_number_of;
108
116
 
109
117
static char *host= NULL, *opt_password= NULL, *user= NULL,
110
118
  *user_supplied_query= NULL,
215
223
  long int timing;
216
224
  uint users;
217
225
  uint real_users;
218
 
  unsigned long long rows;
 
226
  uint64_t rows;
219
227
  long int create_timing;
220
 
  unsigned long long create_count;
 
228
  uint64_t create_count;
221
229
};
222
230
 
223
231
typedef struct thread_context thread_context;
236
244
  long int min_timing;
237
245
  uint users;
238
246
  uint real_users;
239
 
  unsigned long long avg_rows;
 
247
  uint64_t avg_rows;
240
248
  long int sum_of_time;
241
249
  long int std_dev;
242
250
  /* These are just for create time stats */
243
251
  long int create_avg_timing;
244
252
  long int create_max_timing;
245
253
  long int create_min_timing;
246
 
  unsigned long long create_count;
 
254
  uint64_t create_count;
247
255
  /* The following are not used yet */
248
 
  unsigned long long max_rows;
249
 
  unsigned long long min_rows;
 
256
  uint64_t max_rows;
 
257
  uint64_t min_rows;
250
258
};
251
259
 
252
260
static option_string *engine_options= NULL;
316
324
 
317
325
  MY_INIT(argv[0]);
318
326
 
319
 
  load_defaults("my",load_default_groups,&argc,&argv);
 
327
  load_defaults("drizzle",load_default_groups,&argc,&argv);
320
328
  defaults_argv=argv;
321
329
  if (get_options(&argc,&argv))
322
330
  {
346
354
 
347
355
  slap_connect(&drizzle, false);
348
356
 
349
 
  VOID(pthread_mutex_init(&counter_mutex, NULL));
350
 
  VOID(pthread_cond_init(&count_threshhold, NULL));
351
 
  VOID(pthread_mutex_init(&sleeper_mutex, NULL));
352
 
  VOID(pthread_cond_init(&sleep_threshhold, NULL));
353
 
  VOID(pthread_mutex_init(&timer_alarm_mutex, NULL));
354
 
  VOID(pthread_cond_init(&timer_alarm_threshold, NULL));
 
357
  pthread_mutex_init(&counter_mutex, NULL);
 
358
  pthread_cond_init(&count_threshhold, NULL);
 
359
  pthread_mutex_init(&sleeper_mutex, NULL);
 
360
  pthread_cond_init(&sleep_threshhold, NULL);
 
361
  pthread_mutex_init(&timer_alarm_mutex, NULL);
 
362
  pthread_cond_init(&timer_alarm_threshold, NULL);
355
363
 
356
364
 
357
365
  /* Main iterations loop */
387
395
  if (opt_burnin)
388
396
    goto burnin;
389
397
 
390
 
  VOID(pthread_mutex_destroy(&counter_mutex));
391
 
  VOID(pthread_cond_destroy(&count_threshhold));
392
 
  VOID(pthread_mutex_destroy(&sleeper_mutex));
393
 
  VOID(pthread_cond_destroy(&sleep_threshhold));
394
 
  VOID(pthread_mutex_destroy(&timer_alarm_mutex));
395
 
  VOID(pthread_cond_destroy(&timer_alarm_threshold));
 
398
  pthread_mutex_destroy(&counter_mutex);
 
399
  pthread_cond_destroy(&count_threshhold);
 
400
  pthread_mutex_destroy(&sleeper_mutex);
 
401
  pthread_cond_destroy(&sleep_threshhold);
 
402
  pthread_mutex_destroy(&timer_alarm_mutex);
 
403
  pthread_cond_destroy(&timer_alarm_threshold);
396
404
 
397
405
  slap_close(&drizzle);
398
406
 
399
407
  /* now free all the strings we created */
400
408
  if (opt_password)
401
 
    my_free(opt_password, MYF(0));
 
409
    free(opt_password);
402
410
 
403
 
  my_free(concurrency, MYF(0));
 
411
  free(concurrency);
404
412
 
405
413
  statement_cleanup(create_statements);
406
414
  for (x= 0; x < query_statements_count; x++)
407
415
    statement_cleanup(query_statements[x]);
408
 
  my_free(query_statements, MYF(0));
 
416
  free(query_statements);
409
417
  statement_cleanup(pre_statements);
410
418
  statement_cleanup(post_statements);
411
419
  option_cleanup(engine_options);
413
421
 
414
422
#ifdef HAVE_SMEM
415
423
  if (shared_memory_base_name)
416
 
    my_free(shared_memory_base_name, MYF(MY_ALLOW_ZERO_PTR));
 
424
    free(shared_memory_base_name);
417
425
#endif
418
426
  free_defaults(defaults_argv);
419
427
  my_end(my_end_arg);
427
435
  stats *head_sptr;
428
436
  stats *sptr;
429
437
  conclusions conclusion;
430
 
  unsigned long long client_limit;
 
438
  uint64_t client_limit;
431
439
 
432
440
  head_sptr= (stats *)my_malloc(sizeof(stats) * iterations,
433
441
                                MYF(MY_ZEROFILL|MY_FAE|MY_WME));
468
476
      run_query(drizzle, "SET AUTOCOMMIT=0", strlen("SET AUTOCOMMIT=0"));
469
477
 
470
478
    if (pre_system)
471
 
      system(pre_system);
 
479
      assert(system(pre_system)!=-1);
472
480
 
473
481
    /*
474
482
      Pre statements are always run after all other logic so they can
483
491
      run_statements(drizzle, post_statements);
484
492
 
485
493
    if (post_system)
486
 
      system(post_system);
 
494
      assert(system(post_system)!=-1);
487
495
 
488
496
    /* We are finished with this run */
489
497
    if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary)
500
508
  if (opt_csv_str)
501
509
    print_conclusions_csv(&conclusion);
502
510
 
503
 
  my_free(head_sptr, MYF(0));
 
511
  free(head_sptr);
504
512
 
505
513
}
506
514
 
711
719
       license\n");
712
720
  puts("Run a query multiple times against the server\n");
713
721
  printf("Usage: %s [OPTIONS]\n",my_progname);
714
 
  print_defaults("my",load_default_groups);
 
722
  print_defaults("drizzle",load_default_groups);
715
723
  my_print_help(my_long_options);
716
724
}
717
725
 
728
736
    if (argument)
729
737
    {
730
738
      char *start= argument;
731
 
      my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
 
739
      free(opt_password);
732
740
      opt_password= my_strdup(argument,MYF(MY_FAE));
733
741
      while (*argument) *argument++= 'x';    /* Destroy argument */
734
742
      if (*start)
896
904
                                  MYF(MY_ZEROFILL|MY_FAE|MY_WME));
897
905
  ptr->length= table_string.length()+1;
898
906
  ptr->type= CREATE_TABLE_TYPE;
899
 
  stpcpy(ptr->string, table_string.c_str());
 
907
  my_stpcpy(ptr->string, table_string.c_str());
900
908
  return(ptr);
901
909
}
902
910
 
966
974
    ptr->type= UPDATE_TYPE_REQUIRES_PREFIX ;
967
975
  else
968
976
    ptr->type= UPDATE_TYPE;
969
 
  stpcpy(ptr->string, update_string.c_str());
 
977
  my_stpcpy(ptr->string, update_string.c_str());
970
978
  return(ptr);
971
979
}
972
980
 
1086
1094
    }
1087
1095
 
1088
1096
    if (num_blob_cols_size > HUGE_STRING_LENGTH)
1089
 
      my_free(blob_ptr, MYF(0));
 
1097
      free(blob_ptr);
1090
1098
  }
1091
1099
 
1092
1100
  insert_string.append(")", 1);
1103
1111
  }
1104
1112
  ptr->length= insert_string.length()+1;
1105
1113
  ptr->type= INSERT_TYPE;
1106
 
  stpcpy(ptr->string, insert_string.c_str());
 
1114
  my_stpcpy(ptr->string, insert_string.c_str());
1107
1115
  return(ptr);
1108
1116
}
1109
1117
 
1189
1197
    ptr->type= SELECT_TYPE_REQUIRES_PREFIX;
1190
1198
  else
1191
1199
    ptr->type= SELECT_TYPE;
1192
 
  stpcpy(ptr->string, query_string.c_str());
 
1200
  my_stpcpy(ptr->string, query_string.c_str());
1193
1201
  return(ptr);
1194
1202
}
1195
1203
 
1319
1327
 
1320
1328
  if (auto_generate_sql)
1321
1329
  {
1322
 
    unsigned long long x= 0;
 
1330
    uint64_t x= 0;
1323
1331
    statement *ptr_statement;
1324
1332
 
1325
1333
    if (verbose >= 2)
1468
1476
      }
1469
1477
      tmp_string= (char *)my_malloc(sbuf.st_size + 1,
1470
1478
                                    MYF(MY_ZEROFILL|MY_FAE|MY_WME));
1471
 
      my_read(data_file, (uchar*) tmp_string, sbuf.st_size, MYF(0));
 
1479
      my_read(data_file, (unsigned char*) tmp_string, sbuf.st_size, MYF(0));
1472
1480
      tmp_string[sbuf.st_size]= '\0';
1473
1481
      my_close(data_file,MYF(0));
1474
1482
      parse_delimiter(tmp_string, &create_statements, delimiter[0]);
1475
 
      my_free(tmp_string, MYF(0));
 
1483
      free(tmp_string);
1476
1484
    }
1477
1485
    else if (create_string)
1478
1486
    {
1505
1513
      }
1506
1514
      tmp_string= (char *)my_malloc(sbuf.st_size + 1,
1507
1515
                                    MYF(MY_ZEROFILL|MY_FAE|MY_WME));
1508
 
      my_read(data_file, (uchar*) tmp_string, sbuf.st_size, MYF(0));
 
1516
      my_read(data_file, (unsigned char*) tmp_string, sbuf.st_size, MYF(0));
1509
1517
      tmp_string[sbuf.st_size]= '\0';
1510
1518
      my_close(data_file,MYF(0));
1511
1519
      if (user_supplied_query)
1512
1520
        actual_queries= parse_delimiter(tmp_string, &query_statements[0],
1513
1521
                                        delimiter[0]);
1514
 
      my_free(tmp_string, MYF(0));
 
1522
      free(tmp_string);
1515
1523
    }
1516
1524
    else if (user_supplied_query)
1517
1525
    {
1537
1545
    }
1538
1546
    tmp_string= (char *)my_malloc(sbuf.st_size + 1,
1539
1547
                                  MYF(MY_ZEROFILL|MY_FAE|MY_WME));
1540
 
    my_read(data_file, (uchar*) tmp_string, sbuf.st_size, MYF(0));
 
1548
    my_read(data_file, (unsigned char*) tmp_string, sbuf.st_size, MYF(0));
1541
1549
    tmp_string[sbuf.st_size]= '\0';
1542
1550
    my_close(data_file,MYF(0));
1543
1551
    if (user_supplied_pre_statements)
1544
1552
      (void)parse_delimiter(tmp_string, &pre_statements,
1545
1553
                            delimiter[0]);
1546
 
    my_free(tmp_string, MYF(0));
 
1554
    free(tmp_string);
1547
1555
  }
1548
1556
  else if (user_supplied_pre_statements)
1549
1557
  {
1569
1577
    }
1570
1578
    tmp_string= (char *)my_malloc(sbuf.st_size + 1,
1571
1579
                                  MYF(MY_ZEROFILL|MY_FAE|MY_WME));
1572
 
    my_read(data_file, (uchar*) tmp_string, sbuf.st_size, MYF(0));
 
1580
    my_read(data_file, (unsigned char*) tmp_string, sbuf.st_size, MYF(0));
1573
1581
    tmp_string[sbuf.st_size]= '\0';
1574
1582
    my_close(data_file,MYF(0));
1575
1583
    if (user_supplied_post_statements)
1576
1584
      (void)parse_delimiter(tmp_string, &post_statements,
1577
1585
                            delimiter[0]);
1578
 
    my_free(tmp_string, MYF(0));
 
1586
    free(tmp_string);
1579
1587
  }
1580
1588
  else if (user_supplied_post_statements)
1581
1589
  {
1590
1598
    parse_option(default_engine, &engine_options, ',');
1591
1599
 
1592
1600
  if (tty_password)
1593
 
    opt_password= get_tty_password(NullS);
 
1601
    opt_password= get_tty_password(NULL);
1594
1602
  return(0);
1595
1603
}
1596
1604
 
1614
1622
{
1615
1623
  DRIZZLE_RES *result;
1616
1624
  DRIZZLE_ROW row;
1617
 
  unsigned long long counter;
 
1625
  uint64_t counter;
1618
1626
 
1619
1627
 
1620
1628
  /*
1667
1675
static int
1668
1676
drop_primary_key_list(void)
1669
1677
{
1670
 
  unsigned long long counter;
 
1678
  uint64_t counter;
1671
1679
 
1672
1680
  if (primary_keys_number_of)
1673
1681
  {
1674
1682
    for (counter= 0; counter < primary_keys_number_of; counter++)
1675
 
      my_free(primary_keys[counter], MYF(0));
 
1683
      free(primary_keys[counter]);
1676
1684
 
1677
 
    my_free(primary_keys, MYF(0));
 
1685
    free(primary_keys);
1678
1686
  }
1679
1687
 
1680
1688
  return 0;
2115
2123
  pthread_cond_signal(&count_threshhold);
2116
2124
  pthread_mutex_unlock(&counter_mutex);
2117
2125
 
2118
 
  my_free(con, MYF(0));
 
2126
  free(con);
2119
2127
 
2120
2128
  return(0);
2121
2129
}
2287
2295
  printf("\tTotal time for tests: %ld.%03ld seconds\n",
2288
2296
         con->sum_of_time / 1000, con->sum_of_time % 1000);
2289
2297
  printf("\tStandard Deviation: %ld.%03ld\n", con->std_dev / 1000, con->std_dev % 1000);
2290
 
  printf("\tNumber of queries in create queries: %llu\n", con->create_count);
 
2298
  printf("\tNumber of queries in create queries: %"PRIu64"\n", con->create_count);
2291
2299
  printf("\tNumber of clients running queries: %u/%u\n",
2292
2300
         con->users, con->real_users);
2293
2301
  printf("\tNumber of times test was run: %u\n", iterations);
2294
 
  printf("\tAverage number of queries per client: %llu\n", con->avg_rows);
 
2302
  printf("\tAverage number of queries per client: %"PRIu64"\n", con->avg_rows);
2295
2303
  printf("\n");
2296
2304
}
2297
2305
 
2333
2341
    snprintf(label_buffer, HUGE_STRING_LENGTH, "query");
2334
2342
 
2335
2343
  snprintf(buffer, HUGE_STRING_LENGTH,
2336
 
           "%s,%s,%ld.%03ld,%ld.%03ld,%ld.%03ld,%ld.%03ld,%ld.%03ld,%u,%u,%u,%llu\n",
 
2344
           "%s,%s,%ld.%03ld,%ld.%03ld,%ld.%03ld,%ld.%03ld,%ld.%03ld,"
 
2345
           "%u,%u,%u,%"PRIu64"\n",
2337
2346
           con->engine ? con->engine : "", /* Storage engine we ran against */
2338
2347
           label_buffer, /* Load type */
2339
2348
           con->avg_timing / 1000, con->avg_timing % 1000, /* Time to load */
2346
2355
           con->real_users, /* Children used max_timing */
2347
2356
           con->avg_rows  /* Queries run */
2348
2357
           );
2349
 
  my_write(csv_file, (uchar*) buffer, (uint)strlen(buffer), MYF(0));
 
2358
  my_write(csv_file, (unsigned char*) buffer, (uint)strlen(buffer), MYF(0));
2350
2359
}
2351
2360
 
2352
2361
void
2416
2425
  {
2417
2426
    nptr= ptr->next;
2418
2427
    if (ptr->string)
2419
 
      my_free(ptr->string, MYF(0));
 
2428
      free(ptr->string);
2420
2429
    if (ptr->option)
2421
 
      my_free(ptr->option, MYF(0));
2422
 
    my_free(ptr, MYF(0));
 
2430
      free(ptr->option);
 
2431
    free(ptr);
2423
2432
  }
2424
2433
}
2425
2434
 
2434
2443
  {
2435
2444
    nptr= ptr->next;
2436
2445
    if (ptr->string)
2437
 
      my_free(ptr->string, MYF(0));
2438
 
    my_free(ptr, MYF(0));
 
2446
      free(ptr->string);
 
2447
    free(ptr);
2439
2448
  }
2440
2449
}
2441
2450
 
2464
2473
  drizzle_create(drizzle);
2465
2474
 
2466
2475
  if (opt_compress)
2467
 
    drizzle_options(drizzle,DRIZZLE_OPT_COMPRESS,NullS);
 
2476
    drizzle_options(drizzle,DRIZZLE_OPT_COMPRESS,NULL);
2468
2477
 
2469
2478
  for (x= 0; x < 10; x++)
2470
2479
  {