~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/archive/archive_test.c

  • Committer: Brian Aker
  • Date: 2008-07-15 06:45:16 UTC
  • Revision ID: brian@tangent.org-20080715064516-fnbq7kowh7w57bxj
Merge Monty's code.

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