Issue #14428: Use the new time.perf_counter() and time.process_time() functions

 * Replace "time.clock on windows, or time.time" with time.perf_counter()
 * profile module: only use time.process_time() instead of trying different
   functions providing the process time
 * timeit module: use time.perf_counter() by default, time.time() and
   time.clock() can still be used using --time and --clock options
 * pybench program: use time.perf_counter() by default, add support for
   the new time.process_time() and time.perf_counter() functions, but stay
   backward compatible. Use also time.get_clock_info() to display information
   of the timer.
diff --git a/Tools/pybench/pybench.py b/Tools/pybench/pybench.py
index cc1e55c..cac2ddf 100755
--- a/Tools/pybench/pybench.py
+++ b/Tools/pybench/pybench.py
@@ -73,11 +73,15 @@
 
 # Timer types
 TIMER_TIME_TIME = 'time.time'
+TIMER_TIME_PROCESS_TIME = 'time.process_time'
+TIMER_TIME_PERF_COUNTER = 'time.perf_counter'
 TIMER_TIME_CLOCK = 'time.clock'
 TIMER_SYSTIMES_PROCESSTIME = 'systimes.processtime'
 
 # Choose platform default timer
-if sys.platform[:3] == 'win':
+if hasattr(time, 'perf_counter'):
+    TIMER_PLATFORM_DEFAULT = TIMER_TIME_PERF_COUNTER
+elif sys.platform[:3] == 'win':
     # On WinXP this has 2.5ms resolution
     TIMER_PLATFORM_DEFAULT = TIMER_TIME_CLOCK
 else:
@@ -93,6 +97,10 @@
 
     if timertype == TIMER_TIME_TIME:
         return time.time
+    elif timertype == TIMER_TIME_PROCESS_TIME:
+        return time.process_time
+    elif timertype == TIMER_TIME_PERF_COUNTER:
+        return time.perf_counter
     elif timertype == TIMER_TIME_CLOCK:
         return time.clock
     elif timertype == TIMER_SYSTIMES_PROCESSTIME:
@@ -866,7 +874,18 @@
             print('* using timer: systimes.processtime (%s)' % \
                   systimes.SYSTIMES_IMPLEMENTATION)
         else:
+            # Check that the clock function does exist
+            try:
+                get_timer(timer)
+            except TypeError:
+                print("* Error: Unknown timer: %s" % timer)
+                return
+
             print('* using timer: %s' % timer)
+            if hasattr(time, 'get_clock_info'):
+                info = time.get_clock_info(timer[5:])
+                print('* timer: resolution=%s, implementation=%s'
+                      % (info.resolution, info.implementation))
 
         print()