36
36
#include "getopt_long.h"
37
37
#include "libpq/pqcomm.h" /* needed for UNIXSOCK_PATH() */
38
38
#include "pg_config_paths.h"
39
+ #include "portability/instr_time.h"
39
40
40
41
/* for resultmap we need a list of pairs of strings */
41
42
typedef struct _resultmap
@@ -1473,14 +1474,15 @@ results_differ(const char *testname, const char *resultsfile, const char *defaul
1473
1474
1474
1475
/*
1475
1476
* Wait for specified subprocesses to finish, and return their exit
1476
- * statuses into statuses[]
1477
+ * statuses into statuses[] and stop times into stoptimes[]
1477
1478
*
1478
1479
* If names isn't NULL, print each subprocess's name as it finishes
1479
1480
*
1480
1481
* Note: it's OK to scribble on the pids array, but not on the names array
1481
1482
*/
1482
1483
static void
1483
- wait_for_tests (PID_TYPE * pids , int * statuses , char * * names , int num_tests )
1484
+ wait_for_tests (PID_TYPE * pids , int * statuses , instr_time * stoptimes ,
1485
+ char * * names , int num_tests )
1484
1486
{
1485
1487
int tests_left ;
1486
1488
int i ;
@@ -1533,6 +1535,7 @@ wait_for_tests(PID_TYPE * pids, int *statuses, char **names, int num_tests)
1533
1535
#endif
1534
1536
pids [i ] = INVALID_PID ;
1535
1537
statuses [i ] = (int ) exit_status ;
1538
+ INSTR_TIME_SET_CURRENT (stoptimes [i ]);
1536
1539
if (names )
1537
1540
status (" %s" , names [i ]);
1538
1541
tests_left -- ;
@@ -1582,6 +1585,8 @@ run_schedule(const char *schedule, test_function tfunc)
1582
1585
_stringlist * expectfiles [MAX_PARALLEL_TESTS ];
1583
1586
_stringlist * tags [MAX_PARALLEL_TESTS ];
1584
1587
PID_TYPE pids [MAX_PARALLEL_TESTS ];
1588
+ instr_time starttimes [MAX_PARALLEL_TESTS ];
1589
+ instr_time stoptimes [MAX_PARALLEL_TESTS ];
1585
1590
int statuses [MAX_PARALLEL_TESTS ];
1586
1591
_stringlist * ignorelist = NULL ;
1587
1592
char scbuf [1024 ];
@@ -1687,7 +1692,8 @@ run_schedule(const char *schedule, test_function tfunc)
1687
1692
{
1688
1693
status (_ ("test %-28s ... " ), tests [0 ]);
1689
1694
pids [0 ] = (tfunc ) (tests [0 ], & resultfiles [0 ], & expectfiles [0 ], & tags [0 ]);
1690
- wait_for_tests (pids , statuses , NULL , 1 );
1695
+ INSTR_TIME_SET_CURRENT (starttimes [0 ]);
1696
+ wait_for_tests (pids , statuses , stoptimes , NULL , 1 );
1691
1697
/* status line is finished below */
1692
1698
}
1693
1699
else if (max_concurrent_tests > 0 && max_concurrent_tests < num_tests )
@@ -1707,12 +1713,15 @@ run_schedule(const char *schedule, test_function tfunc)
1707
1713
if (i - oldest >= max_connections )
1708
1714
{
1709
1715
wait_for_tests (pids + oldest , statuses + oldest ,
1716
+ stoptimes + oldest ,
1710
1717
tests + oldest , i - oldest );
1711
1718
oldest = i ;
1712
1719
}
1713
1720
pids [i ] = (tfunc ) (tests [i ], & resultfiles [i ], & expectfiles [i ], & tags [i ]);
1721
+ INSTR_TIME_SET_CURRENT (starttimes [i ]);
1714
1722
}
1715
1723
wait_for_tests (pids + oldest , statuses + oldest ,
1724
+ stoptimes + oldest ,
1716
1725
tests + oldest , i - oldest );
1717
1726
status_end ();
1718
1727
}
@@ -1722,8 +1731,9 @@ run_schedule(const char *schedule, test_function tfunc)
1722
1731
for (i = 0 ; i < num_tests ; i ++ )
1723
1732
{
1724
1733
pids [i ] = (tfunc ) (tests [i ], & resultfiles [i ], & expectfiles [i ], & tags [i ]);
1734
+ INSTR_TIME_SET_CURRENT (starttimes [i ]);
1725
1735
}
1726
- wait_for_tests (pids , statuses , tests , num_tests );
1736
+ wait_for_tests (pids , statuses , stoptimes , tests , num_tests );
1727
1737
status_end ();
1728
1738
}
1729
1739
@@ -1793,6 +1803,9 @@ run_schedule(const char *schedule, test_function tfunc)
1793
1803
if (statuses [i ] != 0 )
1794
1804
log_child_failure (statuses [i ]);
1795
1805
1806
+ INSTR_TIME_SUBTRACT (stoptimes [i ], starttimes [i ]);
1807
+ status (_ (" (%.0f ms)" ), INSTR_TIME_GET_MILLISEC (stoptimes [i ]));
1808
+
1796
1809
status_end ();
1797
1810
}
1798
1811
@@ -1818,6 +1831,8 @@ static void
1818
1831
run_single_test (const char * test , test_function tfunc )
1819
1832
{
1820
1833
PID_TYPE pid ;
1834
+ instr_time starttime ;
1835
+ instr_time stoptime ;
1821
1836
int exit_status ;
1822
1837
_stringlist * resultfiles = NULL ;
1823
1838
_stringlist * expectfiles = NULL ;
@@ -1829,7 +1844,8 @@ run_single_test(const char *test, test_function tfunc)
1829
1844
1830
1845
status (_ ("test %-28s ... " ), test );
1831
1846
pid = (tfunc ) (test , & resultfiles , & expectfiles , & tags );
1832
- wait_for_tests (& pid , & exit_status , NULL , 1 );
1847
+ INSTR_TIME_SET_CURRENT (starttime );
1848
+ wait_for_tests (& pid , & exit_status , & stoptime , NULL , 1 );
1833
1849
1834
1850
/*
1835
1851
* Advance over all three lists simultaneously.
@@ -1867,6 +1883,9 @@ run_single_test(const char *test, test_function tfunc)
1867
1883
if (exit_status != 0 )
1868
1884
log_child_failure (exit_status );
1869
1885
1886
+ INSTR_TIME_SUBTRACT (stoptime , starttime );
1887
+ status (_ (" (%.0f ms)" ), INSTR_TIME_GET_MILLISEC (stoptime ));
1888
+
1870
1889
status_end ();
1871
1890
}
1872
1891
0 commit comments