~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/archive/archive_test.c

  • Committer: Monty Taylor
  • Date: 2008-08-04 19:37:18 UTC
  • mto: (261.2.2 codestyle)
  • mto: This revision was merged to the branch mainline in revision 262.
  • Revision ID: monty@inaugust.com-20080804193718-f0rz13uli4429ozb
Changed gettext_noop() to N_()

Show diffs side-by-side

added added

removed removed

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