Skip to content

Commit bae8283

Browse files
committed
Print each test_fsync description while test is running, rather than at
the end.
1 parent 804f96a commit bae8283

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

src/tools/fsync/test_fsync.c

Lines changed: 33 additions & 33 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.30 2010/07/06 19:19:02 momjian Exp $
2+
* $PostgreSQL: pgsql/src/tools/fsync/test_fsync.c,v 1.31 2010/07/13 17:00:50 momjian Exp $
33
*
44
*
55
* test_fsync.c
@@ -80,7 +80,8 @@ main(int argc, char *argv[])
8080
* Simple write
8181
*/
8282
printf("Simple write:\n");
83-
/* write only */
83+
printf(LABEL_FORMAT, "8k write");
84+
fflush(stdout);
8485
gettimeofday(&start_t, NULL);
8586
for (i = 0; i < loops; i++)
8687
{
@@ -91,7 +92,6 @@ main(int argc, char *argv[])
9192
close(tmpfile);
9293
}
9394
gettimeofday(&stop_t, NULL);
94-
printf(LABEL_FORMAT, "8k write");
9595
print_elapse(start_t, stop_t);
9696

9797
/*
@@ -100,7 +100,8 @@ main(int argc, char *argv[])
100100
printf("\nCompare file sync methods using one write:\n");
101101

102102
#ifdef OPEN_DATASYNC_FLAG
103-
/* open_dsync, write */
103+
printf(LABEL_FORMAT, "open_datasync 8k write");
104+
fflush(stdout);
104105
if ((tmpfile = open(filename, O_RDWR | O_DSYNC, 0)) == -1)
105106
die("Cannot open output file.");
106107
gettimeofday(&start_t, NULL);
@@ -113,14 +114,14 @@ main(int argc, char *argv[])
113114
}
114115
gettimeofday(&stop_t, NULL);
115116
close(tmpfile);
116-
printf(LABEL_FORMAT, "open_datasync 8k write");
117117
print_elapse(start_t, stop_t);
118118
#else
119-
printf("\t(open_datasync unavailable)\n");
119+
printf("\t(unavailable: open_datasync)\n");
120120
#endif
121121

122122
#ifdef OPEN_SYNC_FLAG
123-
/* open_fsync, write */
123+
printf(LABEL_FORMAT, "open_sync 8k write");
124+
fflush(stdout);
124125
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG, 0)) == -1)
125126
die("Cannot open output file.");
126127
gettimeofday(&start_t, NULL);
@@ -133,14 +134,14 @@ main(int argc, char *argv[])
133134
}
134135
gettimeofday(&stop_t, NULL);
135136
close(tmpfile);
136-
printf(LABEL_FORMAT, "open_sync 8k write");
137137
print_elapse(start_t, stop_t);
138138
#else
139-
printf("\t(open_sync unavailable)\n");
139+
printf("\t(unavailable: open_sync)\n");
140140
#endif
141141

142142
#ifdef HAVE_FDATASYNC
143-
/* write, fdatasync */
143+
printf(LABEL_FORMAT, "8k write, fdatasync");
144+
fflush(stdout);
144145
if ((tmpfile = open(filename, O_RDWR, 0)) == -1)
145146
die("Cannot open output file.");
146147
gettimeofday(&start_t, NULL);
@@ -154,13 +155,13 @@ main(int argc, char *argv[])
154155
}
155156
gettimeofday(&stop_t, NULL);
156157
close(tmpfile);
157-
printf(LABEL_FORMAT, "8k write, fdatasync");
158158
print_elapse(start_t, stop_t);
159159
#else
160-
printf("\t(fdatasync unavailable)\n");
160+
printf("\t(unavailable: fdatasync)\n");
161161
#endif
162162

163-
/* write, fsync, close */
163+
printf(LABEL_FORMAT, "8k write, fsync");
164+
fflush(stdout);
164165
if ((tmpfile = open(filename, O_RDWR, 0)) == -1)
165166
die("Cannot open output file.");
166167
gettimeofday(&start_t, NULL);
@@ -175,7 +176,6 @@ main(int argc, char *argv[])
175176
}
176177
gettimeofday(&stop_t, NULL);
177178
close(tmpfile);
178-
printf(LABEL_FORMAT, "8k write, fsync");
179179
print_elapse(start_t, stop_t);
180180

181181
/*
@@ -184,7 +184,8 @@ main(int argc, char *argv[])
184184
printf("\nCompare file sync methods using two writes:\n");
185185

186186
#ifdef OPEN_DATASYNC_FLAG
187-
/* open_dsync, write */
187+
printf(LABEL_FORMAT, "2 open_datasync 8k writes");
188+
fflush(stdout);
188189
if ((tmpfile = open(filename, O_RDWR | O_DSYNC, 0)) == -1)
189190
die("Cannot open output file.");
190191
gettimeofday(&start_t, NULL);
@@ -199,14 +200,14 @@ main(int argc, char *argv[])
199200
}
200201
gettimeofday(&stop_t, NULL);
201202
close(tmpfile);
202-
printf(LABEL_FORMAT, "2 open_datasync 8k writes");
203203
print_elapse(start_t, stop_t);
204204
#else
205-
printf("\t(open_datasync unavailable)\n");
205+
printf("\t(unavailable: open_datasync)\n");
206206
#endif
207207

208208
#ifdef OPEN_SYNC_FLAG
209-
/* open_fsync, write */
209+
printf(LABEL_FORMAT, "2 open_sync 8k writes");
210+
fflush(stdout);
210211
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG, 0)) == -1)
211212
die("Cannot open output file.");
212213
gettimeofday(&start_t, NULL);
@@ -221,12 +222,12 @@ main(int argc, char *argv[])
221222
}
222223
gettimeofday(&stop_t, NULL);
223224
close(tmpfile);
224-
printf(LABEL_FORMAT, "2 open_sync 8k writes");
225225
print_elapse(start_t, stop_t);
226226
#endif
227227

228228
#ifdef HAVE_FDATASYNC
229-
/* write, fdatasync */
229+
printf(LABEL_FORMAT, "8k write, 8k write, fdatasync");
230+
fflush(stdout);
230231
if ((tmpfile = open(filename, O_RDWR, 0)) == -1)
231232
die("Cannot open output file.");
232233
gettimeofday(&start_t, NULL);
@@ -242,13 +243,13 @@ main(int argc, char *argv[])
242243
}
243244
gettimeofday(&stop_t, NULL);
244245
close(tmpfile);
245-
printf(LABEL_FORMAT, "8k write, 8k write, fdatasync");
246246
print_elapse(start_t, stop_t);
247247
#else
248-
printf("\t(fdatasync unavailable)\n");
248+
printf("\t(unavailable: fdatasync)\n");
249249
#endif
250250

251-
/* write, fsync, close */
251+
printf(LABEL_FORMAT, "8k write, 8k write, fsync");
252+
fflush(stdout);
252253
if ((tmpfile = open(filename, O_RDWR, 0)) == -1)
253254
die("Cannot open output file.");
254255
gettimeofday(&start_t, NULL);
@@ -265,7 +266,6 @@ main(int argc, char *argv[])
265266
}
266267
gettimeofday(&stop_t, NULL);
267268
close(tmpfile);
268-
printf(LABEL_FORMAT, "8k write, 8k write, fsync");
269269
print_elapse(start_t, stop_t);
270270

271271
/*
@@ -274,7 +274,8 @@ main(int argc, char *argv[])
274274
printf("\nCompare open_sync with different sizes:\n");
275275

276276
#ifdef OPEN_SYNC_FLAG
277-
/* 16k open_sync write */
277+
printf(LABEL_FORMAT, "open_sync 16k write");
278+
fflush(stdout);
278279
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG, 0)) == -1)
279280
die("Cannot open output file.");
280281
gettimeofday(&start_t, NULL);
@@ -287,10 +288,10 @@ main(int argc, char *argv[])
287288
}
288289
gettimeofday(&stop_t, NULL);
289290
close(tmpfile);
290-
printf(LABEL_FORMAT, "open_sync 16k write");
291291
print_elapse(start_t, stop_t);
292292

293-
/* Two 8k open_sync writes */
293+
printf(LABEL_FORMAT, "2 open_sync 8k writes");
294+
fflush(stdout);
294295
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG, 0)) == -1)
295296
die("Cannot open output file.");
296297
gettimeofday(&start_t, NULL);
@@ -305,10 +306,9 @@ main(int argc, char *argv[])
305306
}
306307
gettimeofday(&stop_t, NULL);
307308
close(tmpfile);
308-
printf(LABEL_FORMAT, "2 open_sync 8k writes");
309309
print_elapse(start_t, stop_t);
310310
#else
311-
printf("\t(open_sync unavailable)\n");
311+
printf("\t(unavailable: open_sync)\n");
312312
#endif
313313

314314
/*
@@ -318,7 +318,8 @@ main(int argc, char *argv[])
318318
printf("(If the times are similar, fsync() can sync data written\n");
319319
printf("on a different descriptor.)\n");
320320

321-
/* write, fsync, close */
321+
printf(LABEL_FORMAT, "8k write, fsync, close");
322+
fflush(stdout);
322323
gettimeofday(&start_t, NULL);
323324
for (i = 0; i < loops; i++)
324325
{
@@ -335,10 +336,10 @@ main(int argc, char *argv[])
335336
close(tmpfile);
336337
}
337338
gettimeofday(&stop_t, NULL);
338-
printf(LABEL_FORMAT, "8k write, fsync, close");
339339
print_elapse(start_t, stop_t);
340340

341-
/* write, close, fsync */
341+
printf(LABEL_FORMAT, "8k write, close, fsync");
342+
fflush(stdout);
342343
gettimeofday(&start_t, NULL);
343344
for (i = 0; i < loops; i++)
344345
{
@@ -355,7 +356,6 @@ main(int argc, char *argv[])
355356
close(tmpfile);
356357
}
357358
gettimeofday(&stop_t, NULL);
358-
printf(LABEL_FORMAT, "8k write, close, fsync");
359359
print_elapse(start_t, stop_t);
360360

361361
/* cleanup */

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