mirror of
https://github.com/postgres/postgres.git
synced 2025-07-09 22:41:56 +03:00
Simplify test_fsync duration computation.
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $PostgreSQL: pgsql/src/tools/fsync/test_fsync.c,v 1.28 2010/07/04 01:50:29 momjian Exp $
|
* $PostgreSQL: pgsql/src/tools/fsync/test_fsync.c,v 1.29 2010/07/04 13:42:51 momjian Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* test_fsync.c
|
* test_fsync.c
|
||||||
@ -79,7 +79,7 @@ main(int argc, char *argv[])
|
|||||||
/*
|
/*
|
||||||
* Simple write
|
* Simple write
|
||||||
*/
|
*/
|
||||||
printf("Simple write timing:\n");
|
printf("Simple write:\n");
|
||||||
/* write only */
|
/* write only */
|
||||||
gettimeofday(&start_t, NULL);
|
gettimeofday(&start_t, NULL);
|
||||||
for (i = 0; i < loops; i++)
|
for (i = 0; i < loops; i++)
|
||||||
@ -271,7 +271,7 @@ main(int argc, char *argv[])
|
|||||||
/*
|
/*
|
||||||
* Compare 1 to 2 writes
|
* Compare 1 to 2 writes
|
||||||
*/
|
*/
|
||||||
printf("\nCompare open_sync sizes:\n");
|
printf("\nCompare open_sync with different sizes:\n");
|
||||||
|
|
||||||
#ifdef OPEN_SYNC_FLAG
|
#ifdef OPEN_SYNC_FLAG
|
||||||
/* 16k open_sync write */
|
/* 16k open_sync write */
|
||||||
@ -368,17 +368,10 @@ main(int argc, char *argv[])
|
|||||||
void
|
void
|
||||||
print_elapse(struct timeval start_t, struct timeval stop_t)
|
print_elapse(struct timeval start_t, struct timeval stop_t)
|
||||||
{
|
{
|
||||||
double total_time, per_second;
|
double total_time = (stop_t.tv_sec - start_t.tv_sec) +
|
||||||
|
/* usec subtraction might be negative, e.g. 5.4 - 4.8 */
|
||||||
if (stop_t.tv_usec < start_t.tv_usec)
|
|
||||||
{
|
|
||||||
stop_t.tv_sec--;
|
|
||||||
stop_t.tv_usec += 1000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
total_time = (stop_t.tv_sec - start_t.tv_sec) +
|
|
||||||
(stop_t.tv_usec - start_t.tv_usec) * 0.000001;
|
(stop_t.tv_usec - start_t.tv_usec) * 0.000001;
|
||||||
per_second = loops / total_time;
|
double per_second = loops / total_time;
|
||||||
|
|
||||||
printf("%9.3f/second\n", per_second);
|
printf("%9.3f/second\n", per_second);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user