~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/archive/archive_test.c

  • Committer: Monty Taylor
  • Date: 2008-10-16 06:32:30 UTC
  • mto: (511.1.5 codestyle)
  • mto: This revision was merged to the branch mainline in revision 521.
  • Revision ID: monty@inaugust.com-20081016063230-4brxsra0qsmsg84q
Added -Wunused-macros.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include <assert.h>
19
19
#include <stdio.h>
20
20
#include <string.h>
21
 
#include <my_getopt.h>
22
 
#include <drizzle_version.h>
 
21
#include <mysys/my_getopt.h>
 
22
 
 
23
#if TIME_WITH_SYS_TIME
 
24
# include <sys/time.h>
 
25
# include <time.h>
 
26
#else
 
27
# if HAVE_SYS_TIME_H
 
28
#  include <sys/time.h>
 
29
# else
 
30
#  include <time.h>
 
31
# endif
 
32
#endif  
23
33
 
24
34
#define ARCHIVE_ROW_HEADER_SIZE 4
25
35
 
33
43
 
34
44
char test_string[BUFFER_LEN];
35
45
 
36
 
unsigned long long row_lengths[]= {536870912LL, 2147483648LL, 4294967296LL, 8589934592LL};
37
 
unsigned long long row_numbers[]= {524288LL, 2097152LL, 4194304LL, 8388608LL};
 
46
uint64_t row_lengths[]= {536870912LL, 2147483648LL, 4294967296LL, 8589934592LL};
 
47
uint64_t row_numbers[]= {524288LL, 2097152LL, 4194304LL, 8388608LL};
38
48
 
39
49
/* prototypes */
40
 
int size_test(unsigned long long length, unsigned long long rows_to_test_for, az_method method);
 
50
int size_test(uint64_t length, uint64_t rows_to_test_for, az_method method);
41
51
int small_test(az_method method);
42
52
long int timedif(struct timeval a, struct timeval b);
43
53
 
79
89
      struct timeval start_time, end_time;
80
90
      long int timing;
81
91
 
82
 
      printf("Testing %llu bytes with (%d)\n", row_lengths[x], (int)method);
 
92
      printf("Testing %"PRIu64" bytes with (%d)\n", row_lengths[x], (int)method);
83
93
      gettimeofday(&start_time, NULL);
84
94
      size_test(row_lengths[x], row_numbers[x], method);
85
95
      gettimeofday(&end_time, NULL);
107
117
 
108
118
  unlink(TEST_FILENAME);
109
119
 
110
 
  if (!(ret= azopen(&writer_handle, TEST_FILENAME, O_CREAT|O_RDWR|O_BINARY,
 
120
  if (!(ret= azopen(&writer_handle, TEST_FILENAME, O_CREAT|O_RDWR,
111
121
                    method)))
112
122
  {
113
123
    printf("Could not create test file\n");
127
137
                strlen(FRM_STRING)));
128
138
 
129
139
 
130
 
  if (!(ret= azopen(&reader_handle, TEST_FILENAME, O_RDONLY|O_BINARY,
 
140
  if (!(ret= azopen(&reader_handle, TEST_FILENAME, O_RDONLY,
131
141
                    method)))
132
142
  {
133
143
    printf("Could not open test file\n");
174
184
 
175
185
  azclose(&reader_handle);
176
186
 
177
 
  if (!(ret= azopen(&reader_handle, TEST_FILENAME, O_RDONLY|O_BINARY,
 
187
  if (!(ret= azopen(&reader_handle, TEST_FILENAME, O_RDONLY,
178
188
                    method)))
179
189
  {
180
190
    printf("Could not open test file\n");
229
239
    assert(!memcmp(reader_handle.row_ptr, test_string, ret));
230
240
  }
231
241
 
232
 
  if (!(ret= azopen(&writer_handle, TEST_FILENAME, O_RDWR|O_BINARY, method)))
 
242
  if (!(ret= azopen(&writer_handle, TEST_FILENAME, O_RDWR, method)))
233
243
  {
234
244
    printf("Could not open file (%s) for appending\n", TEST_FILENAME);
235
245
    return 0;
272
282
  return 0;
273
283
}
274
284
 
275
 
int size_test(unsigned long long length, unsigned long long rows_to_test_for, 
 
285
int size_test(uint64_t length, uint64_t rows_to_test_for, 
276
286
              az_method method)
277
287
{
278
288
  azio_stream writer_handle, reader_handle;
279
 
  unsigned long long write_length;
280
 
  unsigned long long read_length;
281
 
  unsigned long long count;
 
289
  uint64_t write_length;
 
290
  uint64_t read_length;
 
291
  uint64_t count;
282
292
  unsigned int ret;
283
293
  int error;
284
294
  int x;
285
295
 
286
296
  if (!(ret= azopen(&writer_handle, TEST_FILENAME, 
287
 
                    O_CREAT|O_RDWR|O_TRUNC|O_BINARY,
 
297
                    O_CREAT|O_RDWR|O_TRUNC,
288
298
                    method)))
289
299
  {
290
300
    printf("Could not create test file\n");
309
319
  assert(write_length == count * BUFFER_LEN); /* Number of rows time BUFFER_LEN */
310
320
  azflush(&writer_handle,  Z_SYNC_FLUSH);
311
321
 
312
 
  if (!(ret= azopen(&reader_handle, TEST_FILENAME, O_RDONLY|O_BINARY,
 
322
  if (!(ret= azopen(&reader_handle, TEST_FILENAME, O_RDONLY,
313
323
                    method)))
314
324
  {
315
325
    printf("Could not open test file\n");
319
329
  /* We do a double loop to test speed */
320
330
  for (x= 0, read_length= 0; x < 2; x++, read_length= 0)
321
331
  {
322
 
    unsigned long long count;
 
332
    uint64_t count;
323
333
 
324
334
    azread_init(&reader_handle);
325
335
    for (count= 0; count < writer_handle.rows; count++)