1
1
/*
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 $
3
3
*
4
4
*
5
5
* test_fsync.c
@@ -80,7 +80,8 @@ main(int argc, char *argv[])
80
80
* Simple write
81
81
*/
82
82
printf ("Simple write:\n" );
83
- /* write only */
83
+ printf (LABEL_FORMAT , "8k write" );
84
+ fflush (stdout );
84
85
gettimeofday (& start_t , NULL );
85
86
for (i = 0 ; i < loops ; i ++ )
86
87
{
@@ -91,7 +92,6 @@ main(int argc, char *argv[])
91
92
close (tmpfile );
92
93
}
93
94
gettimeofday (& stop_t , NULL );
94
- printf (LABEL_FORMAT , "8k write" );
95
95
print_elapse (start_t , stop_t );
96
96
97
97
/*
@@ -100,7 +100,8 @@ main(int argc, char *argv[])
100
100
printf ("\nCompare file sync methods using one write:\n" );
101
101
102
102
#ifdef OPEN_DATASYNC_FLAG
103
- /* open_dsync, write */
103
+ printf (LABEL_FORMAT , "open_datasync 8k write" );
104
+ fflush (stdout );
104
105
if ((tmpfile = open (filename , O_RDWR | O_DSYNC , 0 )) == -1 )
105
106
die ("Cannot open output file." );
106
107
gettimeofday (& start_t , NULL );
@@ -113,14 +114,14 @@ main(int argc, char *argv[])
113
114
}
114
115
gettimeofday (& stop_t , NULL );
115
116
close (tmpfile );
116
- printf (LABEL_FORMAT , "open_datasync 8k write" );
117
117
print_elapse (start_t , stop_t );
118
118
#else
119
- printf ("\t(open_datasync unavailable)\n" );
119
+ printf ("\t(unavailable: open_datasync )\n" );
120
120
#endif
121
121
122
122
#ifdef OPEN_SYNC_FLAG
123
- /* open_fsync, write */
123
+ printf (LABEL_FORMAT , "open_sync 8k write" );
124
+ fflush (stdout );
124
125
if ((tmpfile = open (filename , O_RDWR | OPEN_SYNC_FLAG , 0 )) == -1 )
125
126
die ("Cannot open output file." );
126
127
gettimeofday (& start_t , NULL );
@@ -133,14 +134,14 @@ main(int argc, char *argv[])
133
134
}
134
135
gettimeofday (& stop_t , NULL );
135
136
close (tmpfile );
136
- printf (LABEL_FORMAT , "open_sync 8k write" );
137
137
print_elapse (start_t , stop_t );
138
138
#else
139
- printf ("\t(open_sync unavailable)\n" );
139
+ printf ("\t(unavailable: open_sync )\n" );
140
140
#endif
141
141
142
142
#ifdef HAVE_FDATASYNC
143
- /* write, fdatasync */
143
+ printf (LABEL_FORMAT , "8k write, fdatasync" );
144
+ fflush (stdout );
144
145
if ((tmpfile = open (filename , O_RDWR , 0 )) == -1 )
145
146
die ("Cannot open output file." );
146
147
gettimeofday (& start_t , NULL );
@@ -154,13 +155,13 @@ main(int argc, char *argv[])
154
155
}
155
156
gettimeofday (& stop_t , NULL );
156
157
close (tmpfile );
157
- printf (LABEL_FORMAT , "8k write, fdatasync" );
158
158
print_elapse (start_t , stop_t );
159
159
#else
160
- printf ("\t(fdatasync unavailable)\n" );
160
+ printf ("\t(unavailable: fdatasync )\n" );
161
161
#endif
162
162
163
- /* write, fsync, close */
163
+ printf (LABEL_FORMAT , "8k write, fsync" );
164
+ fflush (stdout );
164
165
if ((tmpfile = open (filename , O_RDWR , 0 )) == -1 )
165
166
die ("Cannot open output file." );
166
167
gettimeofday (& start_t , NULL );
@@ -175,7 +176,6 @@ main(int argc, char *argv[])
175
176
}
176
177
gettimeofday (& stop_t , NULL );
177
178
close (tmpfile );
178
- printf (LABEL_FORMAT , "8k write, fsync" );
179
179
print_elapse (start_t , stop_t );
180
180
181
181
/*
@@ -184,7 +184,8 @@ main(int argc, char *argv[])
184
184
printf ("\nCompare file sync methods using two writes:\n" );
185
185
186
186
#ifdef OPEN_DATASYNC_FLAG
187
- /* open_dsync, write */
187
+ printf (LABEL_FORMAT , "2 open_datasync 8k writes" );
188
+ fflush (stdout );
188
189
if ((tmpfile = open (filename , O_RDWR | O_DSYNC , 0 )) == -1 )
189
190
die ("Cannot open output file." );
190
191
gettimeofday (& start_t , NULL );
@@ -199,14 +200,14 @@ main(int argc, char *argv[])
199
200
}
200
201
gettimeofday (& stop_t , NULL );
201
202
close (tmpfile );
202
- printf (LABEL_FORMAT , "2 open_datasync 8k writes" );
203
203
print_elapse (start_t , stop_t );
204
204
#else
205
- printf ("\t(open_datasync unavailable)\n" );
205
+ printf ("\t(unavailable: open_datasync )\n" );
206
206
#endif
207
207
208
208
#ifdef OPEN_SYNC_FLAG
209
- /* open_fsync, write */
209
+ printf (LABEL_FORMAT , "2 open_sync 8k writes" );
210
+ fflush (stdout );
210
211
if ((tmpfile = open (filename , O_RDWR | OPEN_SYNC_FLAG , 0 )) == -1 )
211
212
die ("Cannot open output file." );
212
213
gettimeofday (& start_t , NULL );
@@ -221,12 +222,12 @@ main(int argc, char *argv[])
221
222
}
222
223
gettimeofday (& stop_t , NULL );
223
224
close (tmpfile );
224
- printf (LABEL_FORMAT , "2 open_sync 8k writes" );
225
225
print_elapse (start_t , stop_t );
226
226
#endif
227
227
228
228
#ifdef HAVE_FDATASYNC
229
- /* write, fdatasync */
229
+ printf (LABEL_FORMAT , "8k write, 8k write, fdatasync" );
230
+ fflush (stdout );
230
231
if ((tmpfile = open (filename , O_RDWR , 0 )) == -1 )
231
232
die ("Cannot open output file." );
232
233
gettimeofday (& start_t , NULL );
@@ -242,13 +243,13 @@ main(int argc, char *argv[])
242
243
}
243
244
gettimeofday (& stop_t , NULL );
244
245
close (tmpfile );
245
- printf (LABEL_FORMAT , "8k write, 8k write, fdatasync" );
246
246
print_elapse (start_t , stop_t );
247
247
#else
248
- printf ("\t(fdatasync unavailable)\n" );
248
+ printf ("\t(unavailable: fdatasync )\n" );
249
249
#endif
250
250
251
- /* write, fsync, close */
251
+ printf (LABEL_FORMAT , "8k write, 8k write, fsync" );
252
+ fflush (stdout );
252
253
if ((tmpfile = open (filename , O_RDWR , 0 )) == -1 )
253
254
die ("Cannot open output file." );
254
255
gettimeofday (& start_t , NULL );
@@ -265,7 +266,6 @@ main(int argc, char *argv[])
265
266
}
266
267
gettimeofday (& stop_t , NULL );
267
268
close (tmpfile );
268
- printf (LABEL_FORMAT , "8k write, 8k write, fsync" );
269
269
print_elapse (start_t , stop_t );
270
270
271
271
/*
@@ -274,7 +274,8 @@ main(int argc, char *argv[])
274
274
printf ("\nCompare open_sync with different sizes:\n" );
275
275
276
276
#ifdef OPEN_SYNC_FLAG
277
- /* 16k open_sync write */
277
+ printf (LABEL_FORMAT , "open_sync 16k write" );
278
+ fflush (stdout );
278
279
if ((tmpfile = open (filename , O_RDWR | OPEN_SYNC_FLAG , 0 )) == -1 )
279
280
die ("Cannot open output file." );
280
281
gettimeofday (& start_t , NULL );
@@ -287,10 +288,10 @@ main(int argc, char *argv[])
287
288
}
288
289
gettimeofday (& stop_t , NULL );
289
290
close (tmpfile );
290
- printf (LABEL_FORMAT , "open_sync 16k write" );
291
291
print_elapse (start_t , stop_t );
292
292
293
- /* Two 8k open_sync writes */
293
+ printf (LABEL_FORMAT , "2 open_sync 8k writes" );
294
+ fflush (stdout );
294
295
if ((tmpfile = open (filename , O_RDWR | OPEN_SYNC_FLAG , 0 )) == -1 )
295
296
die ("Cannot open output file." );
296
297
gettimeofday (& start_t , NULL );
@@ -305,10 +306,9 @@ main(int argc, char *argv[])
305
306
}
306
307
gettimeofday (& stop_t , NULL );
307
308
close (tmpfile );
308
- printf (LABEL_FORMAT , "2 open_sync 8k writes" );
309
309
print_elapse (start_t , stop_t );
310
310
#else
311
- printf ("\t(open_sync unavailable)\n" );
311
+ printf ("\t(unavailable: open_sync )\n" );
312
312
#endif
313
313
314
314
/*
@@ -318,7 +318,8 @@ main(int argc, char *argv[])
318
318
printf ("(If the times are similar, fsync() can sync data written\n" );
319
319
printf ("on a different descriptor.)\n" );
320
320
321
- /* write, fsync, close */
321
+ printf (LABEL_FORMAT , "8k write, fsync, close" );
322
+ fflush (stdout );
322
323
gettimeofday (& start_t , NULL );
323
324
for (i = 0 ; i < loops ; i ++ )
324
325
{
@@ -335,10 +336,10 @@ main(int argc, char *argv[])
335
336
close (tmpfile );
336
337
}
337
338
gettimeofday (& stop_t , NULL );
338
- printf (LABEL_FORMAT , "8k write, fsync, close" );
339
339
print_elapse (start_t , stop_t );
340
340
341
- /* write, close, fsync */
341
+ printf (LABEL_FORMAT , "8k write, close, fsync" );
342
+ fflush (stdout );
342
343
gettimeofday (& start_t , NULL );
343
344
for (i = 0 ; i < loops ; i ++ )
344
345
{
@@ -355,7 +356,6 @@ main(int argc, char *argv[])
355
356
close (tmpfile );
356
357
}
357
358
gettimeofday (& stop_t , NULL );
358
- printf (LABEL_FORMAT , "8k write, close, fsync" );
359
359
print_elapse (start_t , stop_t );
360
360
361
361
/* cleanup */
0 commit comments