Skip to content

Commit 7341a8c

Browse files
committed
Report test_fynsc times in tests per second, instead of total seconds.
1 parent a520b78 commit 7341a8c

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

src/tools/fsync/test_fsync.c

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/src/tools/fsync/test_fsync.c,v 1.27 2010/02/26 02:01:39 momjian Exp $
2+
* $PostgreSQL: pgsql/src/tools/fsync/test_fsync.c,v 1.28 2010/07/04 01:50:29 momjian Exp $
33
*
44
*
55
* test_fsync.c
@@ -34,6 +34,8 @@
3434

3535
#define LABEL_FORMAT "\t%-30s"
3636

37+
int loops = 10000;
38+
3739
void die(char *str);
3840
void print_elapse(struct timeval start_t, struct timeval stop_t);
3941

@@ -43,8 +45,7 @@ main(int argc, char *argv[])
4345
struct timeval start_t;
4446
struct timeval stop_t;
4547
int tmpfile,
46-
i,
47-
loops = 5000;
48+
i;
4849
char *full_buf = (char *) malloc(XLOG_SEG_SIZE),
4950
*buf;
5051
char *filename = FSYNC_FILENAME;
@@ -73,10 +74,12 @@ main(int argc, char *argv[])
7374

7475
buf = (char *) TYPEALIGN(ALIGNOF_XLOG_BUFFER, full_buf);
7576

77+
printf("Loops = %d\n\n", loops);
78+
7679
/*
7780
* Simple write
7881
*/
79-
printf("Simple 8k write timing:\n");
82+
printf("Simple write timing:\n");
8083
/* write only */
8184
gettimeofday(&start_t, NULL);
8285
for (i = 0; i < loops; i++)
@@ -88,13 +91,13 @@ main(int argc, char *argv[])
8891
close(tmpfile);
8992
}
9093
gettimeofday(&stop_t, NULL);
91-
printf(LABEL_FORMAT, "write");
94+
printf(LABEL_FORMAT, "8k write");
9295
print_elapse(start_t, stop_t);
9396

9497
/*
9598
* Compare file sync methods with one 8k write
9699
*/
97-
printf("\nCompare file sync methods using one 8k write:\n");
100+
printf("\nCompare file sync methods using one write:\n");
98101

99102
#ifdef OPEN_DATASYNC_FLAG
100103
/* open_dsync, write */
@@ -110,7 +113,7 @@ main(int argc, char *argv[])
110113
}
111114
gettimeofday(&stop_t, NULL);
112115
close(tmpfile);
113-
printf(LABEL_FORMAT, "open_datasync write");
116+
printf(LABEL_FORMAT, "open_datasync 8k write");
114117
print_elapse(start_t, stop_t);
115118
#else
116119
printf("\t(open_datasync unavailable)\n");
@@ -130,7 +133,7 @@ main(int argc, char *argv[])
130133
}
131134
gettimeofday(&stop_t, NULL);
132135
close(tmpfile);
133-
printf(LABEL_FORMAT, "open_sync write");
136+
printf(LABEL_FORMAT, "open_sync 8k write");
134137
print_elapse(start_t, stop_t);
135138
#else
136139
printf("\t(open_sync unavailable)\n");
@@ -151,7 +154,7 @@ main(int argc, char *argv[])
151154
}
152155
gettimeofday(&stop_t, NULL);
153156
close(tmpfile);
154-
printf(LABEL_FORMAT, "write, fdatasync");
157+
printf(LABEL_FORMAT, "8k write, fdatasync");
155158
print_elapse(start_t, stop_t);
156159
#else
157160
printf("\t(fdatasync unavailable)\n");
@@ -172,13 +175,13 @@ main(int argc, char *argv[])
172175
}
173176
gettimeofday(&stop_t, NULL);
174177
close(tmpfile);
175-
printf(LABEL_FORMAT, "write, fsync");
178+
printf(LABEL_FORMAT, "8k write, fsync");
176179
print_elapse(start_t, stop_t);
177180

178181
/*
179182
* Compare file sync methods with two 8k write
180183
*/
181-
printf("\nCompare file sync methods using two 8k writes:\n");
184+
printf("\nCompare file sync methods using two writes:\n");
182185

183186
#ifdef OPEN_DATASYNC_FLAG
184187
/* open_dsync, write */
@@ -196,7 +199,7 @@ main(int argc, char *argv[])
196199
}
197200
gettimeofday(&stop_t, NULL);
198201
close(tmpfile);
199-
printf(LABEL_FORMAT, "open_datasync write, write");
202+
printf(LABEL_FORMAT, "2 open_datasync 8k writes");
200203
print_elapse(start_t, stop_t);
201204
#else
202205
printf("\t(open_datasync unavailable)\n");
@@ -218,7 +221,7 @@ main(int argc, char *argv[])
218221
}
219222
gettimeofday(&stop_t, NULL);
220223
close(tmpfile);
221-
printf(LABEL_FORMAT, "open_sync write, write");
224+
printf(LABEL_FORMAT, "2 open_sync 8k writes");
222225
print_elapse(start_t, stop_t);
223226
#endif
224227

@@ -239,7 +242,7 @@ main(int argc, char *argv[])
239242
}
240243
gettimeofday(&stop_t, NULL);
241244
close(tmpfile);
242-
printf(LABEL_FORMAT, "write, write, fdatasync");
245+
printf(LABEL_FORMAT, "8k write, 8k write, fdatasync");
243246
print_elapse(start_t, stop_t);
244247
#else
245248
printf("\t(fdatasync unavailable)\n");
@@ -262,7 +265,7 @@ main(int argc, char *argv[])
262265
}
263266
gettimeofday(&stop_t, NULL);
264267
close(tmpfile);
265-
printf(LABEL_FORMAT, "write, write, fsync");
268+
printf(LABEL_FORMAT, "8k write, 8k write, fsync");
266269
print_elapse(start_t, stop_t);
267270

268271
/*
@@ -284,7 +287,7 @@ main(int argc, char *argv[])
284287
}
285288
gettimeofday(&stop_t, NULL);
286289
close(tmpfile);
287-
printf(LABEL_FORMAT, "16k open_sync write");
290+
printf(LABEL_FORMAT, "open_sync 16k write");
288291
print_elapse(start_t, stop_t);
289292

290293
/* Two 8k open_sync writes */
@@ -302,7 +305,7 @@ main(int argc, char *argv[])
302305
}
303306
gettimeofday(&stop_t, NULL);
304307
close(tmpfile);
305-
printf(LABEL_FORMAT, "2 8k open_sync writes");
308+
printf(LABEL_FORMAT, "2 open_sync 8k writes");
306309
print_elapse(start_t, stop_t);
307310
#else
308311
printf("\t(open_sync unavailable)\n");
@@ -311,8 +314,9 @@ main(int argc, char *argv[])
311314
/*
312315
* Fsync another file descriptor?
313316
*/
314-
printf("\nCompare fsync times on write() and new file descriptors (if the times\n");
315-
printf("are similar, fsync() can sync data written on a different descriptor):\n");
317+
printf("\nTest if fsync on non-write file descriptor is honored:\n");
318+
printf("(If the times are similar, fsync() can sync data written\n");
319+
printf("on a different descriptor.)\n");
316320

317321
/* write, fsync, close */
318322
gettimeofday(&start_t, NULL);
@@ -331,7 +335,7 @@ main(int argc, char *argv[])
331335
close(tmpfile);
332336
}
333337
gettimeofday(&stop_t, NULL);
334-
printf(LABEL_FORMAT, "write, fsync, close");
338+
printf(LABEL_FORMAT, "8k write, fsync, close");
335339
print_elapse(start_t, stop_t);
336340

337341
/* write, close, fsync */
@@ -351,7 +355,7 @@ main(int argc, char *argv[])
351355
close(tmpfile);
352356
}
353357
gettimeofday(&stop_t, NULL);
354-
printf(LABEL_FORMAT, "write, close, fsync");
358+
printf(LABEL_FORMAT, "8k write, close, fsync");
355359
print_elapse(start_t, stop_t);
356360

357361
/* cleanup */
@@ -364,14 +368,19 @@ main(int argc, char *argv[])
364368
void
365369
print_elapse(struct timeval start_t, struct timeval stop_t)
366370
{
371+
double total_time, per_second;
372+
367373
if (stop_t.tv_usec < start_t.tv_usec)
368374
{
369375
stop_t.tv_sec--;
370376
stop_t.tv_usec += 1000000;
371377
}
372378

373-
printf("%3ld.%06ld\n", (long) (stop_t.tv_sec - start_t.tv_sec),
374-
(long) (stop_t.tv_usec - start_t.tv_usec));
379+
total_time = (stop_t.tv_sec - start_t.tv_sec) +
380+
(stop_t.tv_usec - start_t.tv_usec) * 0.000001;
381+
per_second = loops / total_time;
382+
383+
printf("%9.3f/second\n", per_second);
375384
}
376385

377386
void

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy