~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/archive/archive_test.c

  • Committer: Lee
  • Date: 2008-10-30 22:02:01 UTC
  • mto: (572.1.2 devel)
  • mto: This revision was merged to the branch mainline in revision 573.
  • Revision ID: lbieber@lbieber-desktop-20081030220201-elb6qprbzpn7c5a4
add my name to the AUTHORS file

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
37
 
 
38
 
#include <boost/scoped_ptr.hpp>
 
32
#endif  
39
33
 
40
34
#define COMMENT_STRING "Your bases"
41
35
#define FRM_STRING "My bases"
58
52
 
59
53
int main(int argc, char *argv[])
60
54
{
61
 
  unsigned int method;
 
55
  az_method method;
62
56
  unsigned int x;
63
57
 
64
58
  if (argc > 2)
65
59
    return 0;
66
60
 
67
 
  drizzled::internal::my_init();
 
61
  my_init();
 
62
 
68
63
  MY_INIT(argv[0]);
69
64
 
70
65
  for (method= AZ_METHOD_BLOCK; method < AZ_METHOD_MAX; method++)
74
69
 
75
70
    printf("Testing %d\n", (int)method);
76
71
    gettimeofday(&start_time, NULL);
77
 
    small_test((az_method)method);
 
72
    small_test(method);
78
73
    gettimeofday(&end_time, NULL);
79
74
    timing= timedif(end_time, start_time);
80
75
    printf("\tTime took %ld.%03ld seconds\n\n", timing / 1000, timing % 1000);
94
89
 
95
90
      printf("Testing %"PRIu64" bytes with (%d)\n", row_lengths[x], (int)method);
96
91
      gettimeofday(&start_time, NULL);
97
 
      size_test(row_lengths[x], row_numbers[x], (az_method)method);
 
92
      size_test(row_lengths[x], row_numbers[x], method);
98
93
      gettimeofday(&end_time, NULL);
99
94
      timing= timedif(end_time, start_time);
100
95
      printf("\tTime took %ld.%03ld seconds\n\n", timing / 1000, timing % 1000);
101
96
    }
102
97
  }
103
98
 
104
 
  drizzled::internal::my_end();
 
99
  my_end(0);
105
100
 
106
101
  return 0;
107
102
}
114
109
  int error;
115
110
  unsigned int x;
116
111
  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();
 
112
  azio_stream writer_handle, reader_handle;
121
113
 
122
114
  memcpy(test_string, TEST_STRING_INIT, 1024);
123
115
 
130
122
    return 0;
131
123
  }
132
124
 
133
 
  azwrite_comment(&writer_handle, (char *)COMMENT_STRING,
 
125
  azwrite_comment(&writer_handle, (char *)COMMENT_STRING, 
134
126
                  (unsigned int)strlen(COMMENT_STRING));
135
127
  azread_comment(&writer_handle, comment_str);
136
128
  assert(!memcmp(COMMENT_STRING, comment_str,
137
129
                strlen(COMMENT_STRING)));
138
130
 
139
 
  azwrite_frm(&writer_handle, (char *)FRM_STRING,
 
131
  azwrite_frm(&writer_handle, (char *)FRM_STRING, 
140
132
                  (unsigned int)strlen(FRM_STRING));
141
133
  azread_frm(&writer_handle, comment_str);
142
134
  assert(!memcmp(FRM_STRING, comment_str,
288
280
  return 0;
289
281
}
290
282
 
291
 
int size_test(uint64_t length, uint64_t rows_to_test_for,
 
283
int size_test(uint64_t length, uint64_t rows_to_test_for, 
292
284
              az_method method)
293
285
{
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();
 
286
  azio_stream writer_handle, reader_handle;
298
287
  uint64_t write_length;
299
288
  uint64_t read_length;
300
289
  uint64_t count;
302
291
  int error;
303
292
  int x;
304
293
 
305
 
  if (!(ret= azopen(&writer_handle, TEST_FILENAME,
 
294
  if (!(ret= azopen(&writer_handle, TEST_FILENAME, 
306
295
                    O_CREAT|O_RDWR|O_TRUNC,
307
296
                    method)))
308
297
  {
310
299
    exit(1);
311
300
  }
312
301
 
313
 
  for (count= 0, write_length= 0; write_length < length ;
 
302
  for (count= 0, write_length= 0; write_length < length ; 
314
303
       write_length+= ret)
315
304
  {
316
305
    count++;
338
327
  /* We do a double loop to test speed */
339
328
  for (x= 0, read_length= 0; x < 2; x++, read_length= 0)
340
329
  {
341
 
    uint64_t read_count;
 
330
    uint64_t count;
342
331
 
343
332
    azread_init(&reader_handle);
344
 
    for (read_count= 0; read_count < writer_handle.rows; read_count++)
 
333
    for (count= 0; count < writer_handle.rows; count++)
345
334
    {
346
335
      ret= azread_row(&reader_handle, &error);
347
336
      read_length+= ret;
368
357
long int timedif(struct timeval a, struct timeval b)
369
358
{
370
359
    register int us, s;
371
 
 
 
360
 
372
361
    us = a.tv_usec - b.tv_usec;
373
362
    us /= 1000;
374
363
    s = a.tv_sec - b.tv_sec;