Skip to content

Commit 3811087

Browse files
author
root
committed
Added reporting to file on response times
1 parent f0a6ac2 commit 3811087

File tree

2 files changed

+41
-19
lines changed

2 files changed

+41
-19
lines changed

src/driver.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ extern int activate_transaction;
2525
extern int counting_on;
2626

2727
extern int num_node;
28+
extern int time_count;
29+
extern FILE *freport_file;
2830

2931
extern int success[];
3032
extern int late[];
@@ -138,6 +140,9 @@ static int do_neword (int t_num)
138140

139141
rt = (double)(tbuf2.tv_sec * 1000.0 + tbuf2.tv_nsec/1000000.0-tbuf1.tv_sec * 1000.0 - tbuf1.tv_nsec/1000000.0);
140142
//printf("NOT : %.3f\n", rt);
143+
if (freport_file != NULL) {
144+
fprintf(freport_file,"%d %.3f\n", time_count, rt);
145+
}
141146

142147
if(rt > max_rt[0])
143148
max_rt[0]=rt;

src/main.c

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ char db_string[DB_STRING_MAX];
3333
char db_host[DB_STRING_MAX];
3434
char db_user[DB_STRING_MAX];
3535
char db_password[DB_STRING_MAX];
36+
char report_file[DB_STRING_MAX]="";
37+
FILE *freport_file=NULL;
3638

3739
int num_ware;
3840
int num_conn;
@@ -44,7 +46,7 @@ int num_node; /* number of servers that consists of cluster i.e. RAC (0:normal m
4446
char node_string[NUM_NODE_MAX][DB_STRING_MAX];
4547

4648
int time_count;
47-
#define PRINT_INTERVAL 10
49+
int PRINT_INTERVAL=10;
4850

4951
int success[5];
5052
int late[5];
@@ -131,27 +133,12 @@ int main( int argc, char *argv[] )
131133
num_node = 0;
132134
arg_offset = 0;
133135

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-
}
149136

150137
clk_tck = sysconf(_SC_CLK_TCK);
151138

152139
/* Parse args */
153140

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) {
155142
switch (c) {
156143
case 'h':
157144
printf ("option h with value '%s'\n", optarg);
@@ -169,6 +156,10 @@ int main( int argc, char *argv[] )
169156
printf ("option p with value '%s'\n", optarg);
170157
strncpy(db_password, optarg, DB_STRING_MAX);
171158
break;
159+
case 'f':
160+
printf ("option f with value '%s'\n", optarg);
161+
strncpy(report_file, optarg, DB_STRING_MAX);
162+
break;
172163
case 'w':
173164
printf ("option w with value '%s'\n", optarg);
174165
num_ware = atoi(optarg);
@@ -185,13 +176,17 @@ int main( int argc, char *argv[] )
185176
printf ("option l with value '%s'\n", optarg);
186177
measure_time = atoi(optarg);
187178
break;
179+
case 'i':
180+
printf ("option i with value '%s'\n", optarg);
181+
PRINT_INTERVAL = atoi(optarg);
182+
break;
188183
case 'P':
189184
printf ("option P with value '%s'\n", optarg);
190185
port = atoi(optarg);
191186
break;
192187
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);
195190
default:
196191
printf ("?? getopt returned character code 0%o ??\n", c);
197192
}
@@ -280,6 +275,11 @@ int main( int argc, char *argv[] )
280275
}
281276
}
282277

278+
if ( strlen(report_file) > 0 ) {
279+
freport_file=fopen(report_file,"w+");
280+
}
281+
282+
283283
printf("<Parameters>\n");
284284
if(is_local==0) {
285285
printf(" [server]: ");
@@ -301,6 +301,22 @@ int main( int argc, char *argv[] )
301301
atoi(argv[11 + arg_offset]), atoi(argv[12 + arg_offset]), atoi(argv[13 + arg_offset]) );
302302
}
303303

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+
304320
fd = open("/dev/urandom", O_RDONLY);
305321
if (fd == -1) {
306322
fd = open("/dev/random", O_RDONLY);
@@ -435,6 +451,7 @@ int main( int argc, char *argv[] )
435451
free(thd_arg);
436452

437453
//hist_report();
454+
fclose(freport_file);
438455

439456
printf("\n<Raw Results>\n");
440457
for ( i=0; i<5; i++ ){

0 commit comments

Comments
 (0)