~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/archive/archive_test.c

  • Committer: Stewart Smith
  • Date: 2008-10-15 04:21:24 UTC
  • mto: This revision was merged to the branch mainline in revision 516.
  • Revision ID: stewart@flamingspork.com-20081015042124-kdmb74bcbky1k1nz
remove my_pthread_[gs]etspecific

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
 
#include <config.h>
17
16
#include "azio.h"
18
17
#include <string.h>
19
18
#include <assert.h>
20
19
#include <stdio.h>
21
20
#include <string.h>
22
 
#include <fcntl.h>
23
 
#include <unistd.h>
24
 
#include <cstdlib>
25
 
#include <memory>
 
21
#include <mysys/my_getopt.h>
26
22
 
27
23
#if TIME_WITH_SYS_TIME
28
24
# include <sys/time.h>
33
29
# else
34
30
#  include <time.h>
35
31
# endif
36
 
#endif
 
32
#endif  
37
33
 
38
 
#include <boost/scoped_ptr.hpp>
 
34
#define ARCHIVE_ROW_HEADER_SIZE 4
39
35
 
40
36
#define COMMENT_STRING "Your bases"
41
37
#define FRM_STRING "My bases"
58
54
 
59
55
int main(int argc, char *argv[])
60
56
{
61
 
  unsigned int method;
 
57
  az_method method;
62
58
  unsigned int x;
63
59
 
64
60
  if (argc > 2)
65
61
    return 0;
66
62
 
67
 
  drizzled::internal::my_init();
 
63
  my_init();
 
64
 
68
65
  MY_INIT(argv[0]);
69
66
 
70
67
  for (method= AZ_METHOD_BLOCK; method < AZ_METHOD_MAX; method++)
74
71
 
75
72
    printf("Testing %d\n", (int)method);
76
73
    gettimeofday(&start_time, NULL);
77
 
    small_test((az_method)method);
 
74
    small_test(method);
78
75
    gettimeofday(&end_time, NULL);
79
76
    timing= timedif(end_time, start_time);
80
77
    printf("\tTime took %ld.%03ld seconds\n\n", timing / 1000, timing % 1000);
94
91
 
95
92
      printf("Testing %"PRIu64" bytes with (%d)\n", row_lengths[x], (int)method);
96
93
      gettimeofday(&start_time, NULL);
97
 
      size_test(row_lengths[x], row_numbers[x], (az_method)method);
 
94
      size_test(row_lengths[x], row_numbers[x], method);
98
95
      gettimeofday(&end_time, NULL);
99
96
      timing= timedif(end_time, start_time);
100
97
      printf("\tTime took %ld.%03ld seconds\n\n", timing / 1000, timing % 1000);
101
98
    }
102
99
  }
103
100
 
104
 
  drizzled::internal::my_end();
 
101
  my_end(0);
105
102
 
106
103
  return 0;
107
104
}
114
111
  int error;
115
112
  unsigned int x;
116
113
  int written_rows= 0;
117
 
  boost::scoped_ptr<azio_stream> writer_handle_ap(new azio_stream);
118
 
  boost::scoped_ptr<azio_stream> reader_handle_ap(new azio_stream);
119
 
  azio_stream &writer_handle= *writer_handle_ap.get();
120
 
  azio_stream &reader_handle= *reader_handle_ap.get();
 
114
  azio_stream writer_handle, reader_handle;
121
115
 
122
116
  memcpy(test_string, TEST_STRING_INIT, 1024);
123
117
 
130
124
    return 0;
131
125
  }
132
126
 
133
 
  azwrite_comment(&writer_handle, (char *)COMMENT_STRING,
 
127
  azwrite_comment(&writer_handle, (char *)COMMENT_STRING, 
134
128
                  (unsigned int)strlen(COMMENT_STRING));
135
129
  azread_comment(&writer_handle, comment_str);
136
130
  assert(!memcmp(COMMENT_STRING, comment_str,
137
131
                strlen(COMMENT_STRING)));
138
132
 
139
 
  azwrite_frm(&writer_handle, (char *)FRM_STRING,
 
133
  azwrite_frm(&writer_handle, (char *)FRM_STRING, 
140
134
                  (unsigned int)strlen(FRM_STRING));
141
135
  azread_frm(&writer_handle, comment_str);
142
136
  assert(!memcmp(FRM_STRING, comment_str,
288
282
  return 0;
289
283
}
290
284
 
291
 
int size_test(uint64_t length, uint64_t rows_to_test_for,
 
285
int size_test(uint64_t length, uint64_t rows_to_test_for, 
292
286
              az_method method)
293
287
{
294
 
  boost::scoped_ptr<azio_stream> writer_handle_ap(new azio_stream);
295
 
  boost::scoped_ptr<azio_stream> reader_handle_ap(new azio_stream);
296
 
  azio_stream &writer_handle= *writer_handle_ap.get();
297
 
  azio_stream &reader_handle= *reader_handle_ap.get();
 
288
  azio_stream writer_handle, reader_handle;
298
289
  uint64_t write_length;
299
290
  uint64_t read_length;
300
291
  uint64_t count;
302
293
  int error;
303
294
  int x;
304
295
 
305
 
  if (!(ret= azopen(&writer_handle, TEST_FILENAME,
 
296
  if (!(ret= azopen(&writer_handle, TEST_FILENAME, 
306
297
                    O_CREAT|O_RDWR|O_TRUNC,
307
298
                    method)))
308
299
  {
310
301
    exit(1);
311
302
  }
312
303
 
313
 
  for (count= 0, write_length= 0; write_length < length ;
 
304
  for (count= 0, write_length= 0; write_length < length ; 
314
305
       write_length+= ret)
315
306
  {
316
307
    count++;
338
329
  /* We do a double loop to test speed */
339
330
  for (x= 0, read_length= 0; x < 2; x++, read_length= 0)
340
331
  {
341
 
    uint64_t read_count;
 
332
    uint64_t count;
342
333
 
343
334
    azread_init(&reader_handle);
344
 
    for (read_count= 0; read_count < writer_handle.rows; read_count++)
 
335
    for (count= 0; count < writer_handle.rows; count++)
345
336
    {
346
337
      ret= azread_row(&reader_handle, &error);
347
338
      read_length+= ret;
368
359
long int timedif(struct timeval a, struct timeval b)
369
360
{
370
361
    register int us, s;
371
 
 
 
362
 
372
363
    us = a.tv_usec - b.tv_usec;
373
364
    us /= 1000;
374
365
    s = a.tv_sec - b.tv_sec;