Skip to content

Commit 105742f

Browse files
committed
Write trx info into trx.out file
1 parent 4921c1e commit 105742f

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

scripts/parse_trx.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import sys
2+
3+
ins = open( sys.argv[1], "r" )
4+
array = {}
5+
if len(sys.argv)>=2:
6+
pref=sys.argv[2]
7+
else:
8+
pref=""
9+
for line in ins:
10+
data=line.split()
11+
if array.has_key(data[3]):
12+
array[data[3]] = array[data[3]]+1
13+
else:
14+
array[data[3]] = 1
15+
16+
minsec=int(min(array.keys()))
17+
maxsec=int(max(array.keys()))
18+
i=minsec
19+
while i<=maxsec:
20+
if array.has_key(str(i)):
21+
print pref,i-minsec,array[str(i)]
22+
else:
23+
print pref,i-minsec,0
24+
i=i+1

src/main.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ char db_user[DB_STRING_MAX];
3535
char db_password[DB_STRING_MAX];
3636
char report_file[DB_STRING_MAX]="";
3737
FILE *freport_file=NULL;
38+
char trx_file[DB_STRING_MAX]="";
39+
FILE *ftrx_file=NULL;
3840

3941
int num_ware;
4042
int num_conn;
@@ -139,7 +141,7 @@ int main( int argc, char *argv[] )
139141

140142
/* Parse args */
141143

142-
while ( (c = getopt(argc, argv, "h:P:d:u:p:w:c:r:l:i:f:")) != -1) {
144+
while ( (c = getopt(argc, argv, "h:P:d:u:p:w:c:r:l:i:f:t:")) != -1) {
143145
switch (c) {
144146
case 'h':
145147
printf ("option h with value '%s'\n", optarg);
@@ -161,6 +163,10 @@ int main( int argc, char *argv[] )
161163
printf ("option f with value '%s'\n", optarg);
162164
strncpy(report_file, optarg, DB_STRING_MAX);
163165
break;
166+
case 't':
167+
printf ("option t with value '%s'\n", optarg);
168+
strncpy(trx_file, optarg, DB_STRING_MAX);
169+
break;
164170
case 'w':
165171
printf ("option w with value '%s'\n", optarg);
166172
num_ware = atoi(optarg);
@@ -186,7 +192,7 @@ int main( int argc, char *argv[] )
186192
port = atoi(optarg);
187193
break;
188194
case '?':
189-
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");
195+
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 -t trx_file\n");
190196
exit(0);
191197
default:
192198
printf ("?? getopt returned character code 0%o ??\n", c);
@@ -280,6 +286,10 @@ int main( int argc, char *argv[] )
280286
freport_file=fopen(report_file,"w+");
281287
}
282288

289+
if ( strlen(trx_file) > 0 ) {
290+
ftrx_file=fopen(trx_file,"w+");
291+
}
292+
283293

284294
printf("<Parameters>\n");
285295
if(is_local==0) {
@@ -455,6 +465,9 @@ int main( int argc, char *argv[] )
455465
if (freport_file != NULL)
456466
fclose(freport_file);
457467

468+
if (ftrx_file != NULL)
469+
fclose(ftrx_file);
470+
458471
printf("\n<Raw Results>\n");
459472
for ( i=0; i<5; i++ ){
460473
printf(" [%d] sc:%d lt:%d rt:%d fl:%d \n", i, success[i], late[i], retry[i], failure[i]);

src/neword.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ case 10: strncpy(ol_dist_info, s_dist_10, 25); break; \
3030
extern MYSQL **ctx;
3131
extern MYSQL_STMT ***stmt;
3232

33+
extern FILE *ftrx_file;
34+
3335
#define NNULL ((void *)0)
3436

3537
/*
@@ -94,6 +96,9 @@ int neword( int t_num,
9496
int ol_num_seq[MAX_NUM_ITEMS];
9597

9698
int proceed = 0;
99+
struct timespec tbuf1;
100+
clock_t clk1;
101+
97102

98103
MYSQL_STMT* mysql_stmt;
99104
MYSQL_BIND param[9];
@@ -497,6 +502,8 @@ int neword( int t_num,
497502

498503
/*EXEC_SQL COMMIT WORK;*/
499504
if( mysql_commit(ctx[t_num]) ) goto sqlerr;
505+
clk1 = clock_gettime(CLOCK_REALTIME, &tbuf1 );
506+
fprintf(ftrx_file,"t_num: %d finish: %lu %lu start: %s\n",t_num, tbuf1.tv_sec, tbuf1.tv_nsec,datetime);
500507

501508
return (1);
502509

0 commit comments

Comments
 (0)