Skip to content

Commit 2330d9c

Browse files
committed
Simplify test_fsync duration computation.
1 parent 7341a8c commit 2330d9c

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/tools/fsync/test_fsync.c

Lines changed: 6 additions & 13 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.28 2010/07/04 01:50:29 momjian Exp $
2+
* $PostgreSQL: pgsql/src/tools/fsync/test_fsync.c,v 1.29 2010/07/04 13:42:51 momjian Exp $
33
*
44
*
55
* test_fsync.c
@@ -79,7 +79,7 @@ main(int argc, char *argv[])
7979
/*
8080
* Simple write
8181
*/
82-
printf("Simple write timing:\n");
82+
printf("Simple write:\n");
8383
/* write only */
8484
gettimeofday(&start_t, NULL);
8585
for (i = 0; i < loops; i++)
@@ -271,7 +271,7 @@ main(int argc, char *argv[])
271271
/*
272272
* Compare 1 to 2 writes
273273
*/
274-
printf("\nCompare open_sync sizes:\n");
274+
printf("\nCompare open_sync with different sizes:\n");
275275

276276
#ifdef OPEN_SYNC_FLAG
277277
/* 16k open_sync write */
@@ -368,17 +368,10 @@ main(int argc, char *argv[])
368368
void
369369
print_elapse(struct timeval start_t, struct timeval stop_t)
370370
{
371-
double total_time, per_second;
372-
373-
if (stop_t.tv_usec < start_t.tv_usec)
374-
{
375-
stop_t.tv_sec--;
376-
stop_t.tv_usec += 1000000;
377-
}
378-
379-
total_time = (stop_t.tv_sec - start_t.tv_sec) +
371+
double total_time = (stop_t.tv_sec - start_t.tv_sec) +
372+
/* usec subtraction might be negative, e.g. 5.4 - 4.8 */
380373
(stop_t.tv_usec - start_t.tv_usec) * 0.000001;
381-
per_second = loops / total_time;
374+
double per_second = loops / total_time;
382375

383376
printf("%9.3f/second\n", per_second);
384377
}

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