33
42
char test_string[BUFFER_LEN];
35
unsigned long long row_lengths[]= {536870912LL, 2147483648LL, 4294967296LL, 8589934592LL};
36
unsigned long long row_numbers[]= {524288LL, 2097152LL, 4194304LL, 8388608LL};
44
uint64_t row_lengths[]= {536870912LL, 2147483648LL, 4294967296LL, 8589934592LL};
45
uint64_t row_numbers[]= {524288LL, 2097152LL, 4194304LL, 8388608LL};
39
int size_test(unsigned long long length, unsigned long long rows_to_test_for, az_method method);
48
int size_test(uint64_t length, uint64_t rows_to_test_for, az_method method);
40
49
int small_test(az_method method);
41
50
long int timedif(struct timeval a, struct timeval b);
78
87
struct timeval start_time, end_time;
81
printf("Testing %llu bytes with (%d)\n", row_lengths[x], (int)method);
90
printf("Testing %"PRIu64" bytes with (%d)\n", row_lengths[x], (int)method);
82
91
gettimeofday(&start_time, NULL);
83
92
size_test(row_lengths[x], row_numbers[x], method);
84
93
gettimeofday(&end_time, NULL);
107
116
unlink(TEST_FILENAME);
109
if (!(ret= azopen(&writer_handle, TEST_FILENAME, O_CREAT|O_RDWR|O_BINARY,
118
if (!(ret= azopen(&writer_handle, TEST_FILENAME, O_CREAT|O_RDWR,
112
121
printf("Could not create test file\n");
116
azwrite_comment(&writer_handle, (char *)COMMENT_STRING,
125
azwrite_comment(&writer_handle, (char *)COMMENT_STRING,
117
126
(unsigned int)strlen(COMMENT_STRING));
118
127
azread_comment(&writer_handle, comment_str);
119
128
assert(!memcmp(COMMENT_STRING, comment_str,
120
129
strlen(COMMENT_STRING)));
122
azwrite_frm(&writer_handle, (char *)FRM_STRING,
131
azwrite_frm(&writer_handle, (char *)FRM_STRING,
123
132
(unsigned int)strlen(FRM_STRING));
124
133
azread_frm(&writer_handle, comment_str);
125
134
assert(!memcmp(FRM_STRING, comment_str,
126
135
strlen(FRM_STRING)));
129
if (!(ret= azopen(&reader_handle, TEST_FILENAME, O_RDONLY|O_BINARY,
138
if (!(ret= azopen(&reader_handle, TEST_FILENAME, O_RDONLY,
132
141
printf("Could not open test file\n");
174
183
azclose(&reader_handle);
176
if (!(ret= azopen(&reader_handle, TEST_FILENAME, O_RDONLY|O_BINARY,
185
if (!(ret= azopen(&reader_handle, TEST_FILENAME, O_RDONLY,
179
188
printf("Could not open test file\n");
228
237
assert(!memcmp(reader_handle.row_ptr, test_string, ret));
231
if (!(ret= azopen(&writer_handle, TEST_FILENAME, O_RDWR|O_BINARY, method)))
240
if (!(ret= azopen(&writer_handle, TEST_FILENAME, O_RDWR, method)))
233
242
printf("Could not open file (%s) for appending\n", TEST_FILENAME);
274
int size_test(unsigned long long length, unsigned long long rows_to_test_for,
283
int size_test(uint64_t length, uint64_t rows_to_test_for,
275
284
az_method method)
277
286
azio_stream writer_handle, reader_handle;
278
unsigned long long write_length;
279
unsigned long long read_length;
280
unsigned long long count;
287
uint64_t write_length;
288
uint64_t read_length;
281
290
unsigned int ret;
285
if (!(ret= azopen(&writer_handle, TEST_FILENAME,
286
O_CREAT|O_RDWR|O_TRUNC|O_BINARY,
294
if (!(ret= azopen(&writer_handle, TEST_FILENAME,
295
O_CREAT|O_RDWR|O_TRUNC,
289
298
printf("Could not create test file\n");
293
for (count= 0, write_length= 0; write_length < length ;
302
for (count= 0, write_length= 0; write_length < length ;
294
303
write_length+= ret)
308
317
assert(write_length == count * BUFFER_LEN); /* Number of rows time BUFFER_LEN */
309
318
azflush(&writer_handle, Z_SYNC_FLUSH);
311
if (!(ret= azopen(&reader_handle, TEST_FILENAME, O_RDONLY|O_BINARY,
320
if (!(ret= azopen(&reader_handle, TEST_FILENAME, O_RDONLY,
314
323
printf("Could not open test file\n");
318
327
/* We do a double loop to test speed */
319
328
for (x= 0, read_length= 0; x < 2; x++, read_length= 0)
321
unsigned long long count;
323
332
azread_init(&reader_handle);
324
for (count= 0; count < writer_handle.rows; count++)
333
for (read_count= 0; read_count < writer_handle.rows; read_count++)
326
335
ret= azread_row(&reader_handle, &error);
327
336
read_length+= ret;