/*
- * $PostgreSQL: pgsql/src/tools/fsync/test_fsync.c,v 1.24 2009/08/10 18:19:06 momjian Exp $
+ * $PostgreSQL: pgsql/src/tools/fsync/test_fsync.c,v 1.25 2009/09/21 20:20:56 momjian Exp $
*
*
* test_fsync.c
die("Cannot open output file.");
gettimeofday(&start_t, NULL);
for (i = 0; i < loops; i++)
+ {
if (write(tmpfile, buf, WRITE_SIZE) != WRITE_SIZE)
die("write failed");
+ if (lseek(tmpfile, 0, SEEK_SET) == -1)
+ die("seek failed");
+ }
gettimeofday(&elapse_t, NULL);
close(tmpfile);
printf("\tone 16k o_sync write ");
die("write failed");
if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
die("write failed");
+ if (lseek(tmpfile, 0, SEEK_SET) == -1)
+ die("seek failed");
}
gettimeofday(&elapse_t, NULL);
close(tmpfile);
die("Cannot open output file.");
gettimeofday(&start_t, NULL);
for (i = 0; i < loops; i++)
+ {
if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
die("write failed");
+ if (lseek(tmpfile, 0, SEEK_SET) == -1)
+ die("seek failed");
+ }
gettimeofday(&elapse_t, NULL);
close(tmpfile);
printf("\topen o_dsync, write ");
die("Cannot open output file.");
gettimeofday(&start_t, NULL);
for (i = 0; i < loops; i++)
+ {
if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
die("write failed");
+ if (lseek(tmpfile, 0, SEEK_SET) == -1)
+ die("seek failed");
+ }
gettimeofday(&elapse_t, NULL);
close(tmpfile);
printf("\topen o_sync, write ");
if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
die("write failed");
fdatasync(tmpfile);
+ if (lseek(tmpfile, 0, SEEK_SET) == -1)
+ die("seek failed");
}
gettimeofday(&elapse_t, NULL);
close(tmpfile);
die("write failed");
if (fsync(tmpfile) != 0)
die("fsync failed");
+ if (lseek(tmpfile, 0, SEEK_SET) == -1)
+ die("seek failed");
}
gettimeofday(&elapse_t, NULL);
close(tmpfile);
die("write failed");
if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
die("write failed");
+ if (lseek(tmpfile, 0, SEEK_SET) == -1)
+ die("seek failed");
}
gettimeofday(&elapse_t, NULL);
close(tmpfile);
die("write failed");
if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
die("write failed");
+ if (lseek(tmpfile, 0, SEEK_SET) == -1)
+ die("seek failed");
}
gettimeofday(&elapse_t, NULL);
close(tmpfile);
if (write(tmpfile, buf, WRITE_SIZE / 2) != WRITE_SIZE / 2)
die("write failed");
fdatasync(tmpfile);
+ if (lseek(tmpfile, 0, SEEK_SET) == -1)
+ die("seek failed");
}
gettimeofday(&elapse_t, NULL);
close(tmpfile);
die("write failed");
if (fsync(tmpfile) != 0)
die("fsync failed");
+ if (lseek(tmpfile, 0, SEEK_SET) == -1)
+ die("seek failed");
}
gettimeofday(&elapse_t, NULL);
close(tmpfile);