@@ -33,6 +33,8 @@ char db_string[DB_STRING_MAX];
33
33
char db_host [DB_STRING_MAX ];
34
34
char db_user [DB_STRING_MAX ];
35
35
char db_password [DB_STRING_MAX ];
36
+ char report_file [DB_STRING_MAX ]= "" ;
37
+ FILE * freport_file = NULL ;
36
38
37
39
int num_ware ;
38
40
int num_conn ;
@@ -44,7 +46,7 @@ int num_node; /* number of servers that consists of cluster i.e. RAC (0:normal m
44
46
char node_string [NUM_NODE_MAX ][DB_STRING_MAX ];
45
47
46
48
int time_count ;
47
- #define PRINT_INTERVAL 10
49
+ int PRINT_INTERVAL = 10 ;
48
50
49
51
int success [5 ];
50
52
int late [5 ];
@@ -131,27 +133,12 @@ int main( int argc, char *argv[] )
131
133
num_node = 0 ;
132
134
arg_offset = 0 ;
133
135
134
- /* alarm initialize */
135
- time_count = 0 ;
136
- itval .it_interval .tv_sec = PRINT_INTERVAL ;
137
- itval .it_interval .tv_usec = 0 ;
138
- itval .it_value .tv_sec = PRINT_INTERVAL ;
139
- itval .it_value .tv_usec = 0 ;
140
- sigact .sa_handler = alarm_handler ;
141
- sigact .sa_flags = 0 ;
142
- sigemptyset (& sigact .sa_mask );
143
-
144
- /* setup handler&timer */
145
- if ( sigaction ( SIGALRM , & sigact , NULL ) == -1 ) {
146
- fprintf (stderr , "error in sigaction()\n" );
147
- exit (1 );
148
- }
149
136
150
137
clk_tck = sysconf (_SC_CLK_TCK );
151
138
152
139
/* Parse args */
153
140
154
- while ( (c = getopt (argc , argv , "h:P:d:u:p:w:c:r:l:" )) != -1 ) {
141
+ while ( (c = getopt (argc , argv , "h:P:d:u:p:w:c:r:l:i:f: " )) != -1 ) {
155
142
switch (c ) {
156
143
case 'h' :
157
144
printf ("option h with value '%s'\n" , optarg );
@@ -169,6 +156,10 @@ int main( int argc, char *argv[] )
169
156
printf ("option p with value '%s'\n" , optarg );
170
157
strncpy (db_password , optarg , DB_STRING_MAX );
171
158
break ;
159
+ case 'f' :
160
+ printf ("option f with value '%s'\n" , optarg );
161
+ strncpy (report_file , optarg , DB_STRING_MAX );
162
+ break ;
172
163
case 'w' :
173
164
printf ("option w with value '%s'\n" , optarg );
174
165
num_ware = atoi (optarg );
@@ -185,13 +176,17 @@ int main( int argc, char *argv[] )
185
176
printf ("option l with value '%s'\n" , optarg );
186
177
measure_time = atoi (optarg );
187
178
break ;
179
+ case 'i' :
180
+ printf ("option i with value '%s'\n" , optarg );
181
+ PRINT_INTERVAL = atoi (optarg );
182
+ break ;
188
183
case 'P' :
189
184
printf ("option P with value '%s'\n" , optarg );
190
185
port = atoi (optarg );
191
186
break ;
192
187
case '?' :
193
- printf ("\n usage : tpcc_start -h server_host -P port -d database_name -u mysql_user -p mysql_password -w warehouses -c connections -r warmup_time -l running_time\n" );
194
- break ;
188
+ printf ("Usage : tpcc_start -h server_host -P port -d database_name -u mysql_user -p mysql_password -w warehouses -c connections -r warmup_time -l running_time -i report_interval -f report_file \n" );
189
+ exit ( 0 ) ;
195
190
default :
196
191
printf ("?? getopt returned character code 0%o ??\n" , c );
197
192
}
@@ -280,6 +275,11 @@ int main( int argc, char *argv[] )
280
275
}
281
276
}
282
277
278
+ if ( strlen (report_file ) > 0 ) {
279
+ freport_file = fopen (report_file ,"w+" );
280
+ }
281
+
282
+
283
283
printf ("<Parameters>\n" );
284
284
if (is_local == 0 ) {
285
285
printf (" [server]: " );
@@ -301,6 +301,22 @@ int main( int argc, char *argv[] )
301
301
atoi (argv [11 + arg_offset ]), atoi (argv [12 + arg_offset ]), atoi (argv [13 + arg_offset ]) );
302
302
}
303
303
304
+ /* alarm initialize */
305
+ time_count = 0 ;
306
+ itval .it_interval .tv_sec = PRINT_INTERVAL ;
307
+ itval .it_interval .tv_usec = 0 ;
308
+ itval .it_value .tv_sec = PRINT_INTERVAL ;
309
+ itval .it_value .tv_usec = 0 ;
310
+ sigact .sa_handler = alarm_handler ;
311
+ sigact .sa_flags = 0 ;
312
+ sigemptyset (& sigact .sa_mask );
313
+
314
+ /* setup handler&timer */
315
+ if ( sigaction ( SIGALRM , & sigact , NULL ) == -1 ) {
316
+ fprintf (stderr , "error in sigaction()\n" );
317
+ exit (1 );
318
+ }
319
+
304
320
fd = open ("/dev/urandom" , O_RDONLY );
305
321
if (fd == -1 ) {
306
322
fd = open ("/dev/random" , O_RDONLY );
@@ -435,6 +451,7 @@ int main( int argc, char *argv[] )
435
451
free (thd_arg );
436
452
437
453
//hist_report();
454
+ fclose (freport_file );
438
455
439
456
printf ("\n<Raw Results>\n" );
440
457
for ( i = 0 ; i < 5 ; i ++ ){
0 commit comments