~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/archive/archive_performance.cc

  • Committer: Brian Aker
  • Date: 2009-12-29 01:38:38 UTC
  • mfrom: (1251.1.1 drizzle)
  • Revision ID: brian@gaz-20091229013838-03kb2z5xbqw03ddt
Merge of Diego fix.

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
18
#include "azio.h"
17
19
#include <string.h>
18
20
#include <assert.h>
19
21
#include <stdio.h>
20
22
#include <stdlib.h>
21
23
#include <string.h>
22
 
#include <mysys/my_getopt.h>
23
 
 
24
 
#define ARCHIVE_ROW_HEADER_SIZE 4
25
 
 
26
 
#define COMMENT_STRING "Your bases"
27
 
#define FRM_STRING "My bases"
 
24
#include <fcntl.h>
 
25
#include <sys/stat.h>
 
26
#include "drizzled/my_getopt.h"
 
27
 
 
28
#if TIME_WITH_SYS_TIME
 
29
# include <sys/time.h>
 
30
# include <time.h>
 
31
#else
 
32
# if HAVE_SYS_TIME_H
 
33
#  include <sys/time.h>
 
34
# else
 
35
#  include <time.h>
 
36
# endif
 
37
#endif
 
38
 
 
39
 
28
40
#define TEST_FILENAME "performance_test.az"
29
 
#define TEST_STRING_INIT "YOU don't know about me without you have read a book by the name of The Adventures of Tom Sawyer; but that ain't no matter.  That book was made by Mr. Mark Twain, and he told the truth, mainly.  There was things which he stretched, but mainly he told the truth.  That is nothing.  I never seen anybody but lied one time or another, without it was Aunt Polly, or the widow, or maybe Mary.  Aunt Polly--Tom's Aunt Polly, she is--and Mary, and the Widow Douglas is all told about in that book, which is mostly a true book, with some stretchers, as I said before.  Now the way that the book winds up is this:  Tom and me found the money that the robbers hid in the cave, and it made us rich.  We got six thousand dollars apiece--all gold.  It was an awful sight of money when it was piled up.  Well, Judge Thatcher he took it and put it out at interest, and it fetched us a dollar a day apiece all the year round --more than a body could tell what to do with.  The Widow Douglas she took me for her son, and allowed she would..."
30
 
#define TEST_LOOP_NUM 100
31
 
 
32
 
 
33
 
#define ARCHIVE_ROW_HEADER_SIZE 4
34
41
 
35
42
#define BUFFER_LEN 1024
36
43
 
39
46
#define ROWS_TO_TEST 2000000LL
40
47
 
41
48
/* prototypes */
42
 
long int timedif(struct timeval a, struct timeval b);
43
 
int generate_data(unsigned long long length);
44
 
int read_test(azio_stream *reader_handle, unsigned long long rows_to_test_for);
 
49
static long int timedif(struct timeval a, struct timeval b);
 
50
static int generate_data(uint64_t length);
 
51
static int read_test(azio_stream *reader_handle, uint64_t rows_to_test_for);
45
52
 
46
53
int main(int argc, char *argv[])
47
54
{
64
71
    azio_stream reader_handle;
65
72
 
66
73
    if (method)
67
 
      printf("Performing aio_read() test\n");
 
74
      printf("Performing azio_read() test\n");
68
75
    else
69
76
      printf("Performing read() test\n");
70
77
 
71
 
    if (!(ret= azopen(&reader_handle, TEST_FILENAME, O_RDONLY|O_BINARY,
72
 
                    method)))
 
78
    if (!(ret= azopen(&reader_handle, TEST_FILENAME, O_RDONLY,
 
79
                      (az_method)method)))
73
80
    {
74
81
      printf("Could not open test file\n");
75
82
      return 0;
84
91
    azclose(&reader_handle);
85
92
  }
86
93
 
87
 
  my_end(0);
 
94
  my_end();
88
95
 
89
96
  return 0;
90
97
}
91
98
 
92
 
int generate_data(unsigned long long rows_to_test)
 
99
static int generate_data(uint64_t rows_to_test)
93
100
{
94
101
  azio_stream writer_handle;
95
 
  unsigned long long x;
 
102
  uint64_t x;
96
103
  unsigned int ret;
97
104
  struct timeval start_time, end_time;
98
105
  long int timing;
104
111
    return 0;
105
112
  }
106
113
 
107
 
  if (!(ret= azopen(&writer_handle, TEST_FILENAME, O_CREAT|O_RDWR|O_TRUNC|O_BINARY,
 
114
  if (!(ret= azopen(&writer_handle, TEST_FILENAME, O_CREAT|O_RDWR|O_TRUNC,
108
115
                    AZ_METHOD_BLOCK)))
109
116
  {
110
117
    printf("Could not create test file\n");
125
132
      azflush(&writer_handle,  Z_SYNC_FLUSH);
126
133
    }
127
134
  }
128
 
  /* 
129
 
    We put the flush in just to be honest with write speed, normally azclose 
 
135
  /*
 
136
    We put the flush in just to be honest with write speed, normally azclose
130
137
    would be fine.
131
138
  */
132
139
  azflush(&writer_handle,  Z_SYNC_FLUSH);
140
147
  return 0;
141
148
}
142
149
 
143
 
int read_test(azio_stream *reader_handle, unsigned long long rows_to_test_for)
 
150
static int read_test(azio_stream *reader_handle, uint64_t rows_to_test_for)
144
151
{
145
 
  unsigned long long read_length= 0;
146
 
  unsigned long long count= 0;
 
152
  uint64_t read_length= 0;
 
153
  uint64_t count= 0;
147
154
  unsigned int ret;
148
155
  int error;
149
156
 
152
159
  {
153
160
    if (error)
154
161
    {
155
 
      fprintf(stderr, "Got an error while reading at row %llu\n", count);
 
162
      fprintf(stderr, "Got an error while reading at row %"PRIu64"\n", count);
156
163
      exit(1);
157
164
    }
158
165
 
170
177
  return 0;
171
178
}
172
179
 
173
 
long int timedif(struct timeval a, struct timeval b)
 
180
static long int timedif(struct timeval a, struct timeval b)
174
181
{
175
182
    register int us, s;
176
 
 
 
183
 
177
184
    us = a.tv_usec - b.tv_usec;
178
185
    us /= 1000;
179
186
    s = a.tv_sec - b.tv_sec;