min(timer total( str upper'spam'for in range( )( 'spam'taking the min of an iteration of total results this way has similar effect because the times in the result tuples dominate comparisons made by min (they are leftmost in the tuplewe could use this in our module too (and will in later variations)it varies slightly by omitting very small overhead in the best-of function' code and not nesting result tuplesthough either result suffices for relative comparisons as isthe best-of function must pick high initial lowest time value--though years is probably longer than most of the tests you're likely to run(((( * (((( * / / / / plus few extra days floorsee new timer calls in this section uses the time module' clock and time calls because they apply to all readers of this book python introduces new interfaces in this module that are designed to be more portable specificallythe behavior of this module' clock and time calls varies per platformbut its new perf_counter and process_time functions have well-defined and platform-neutral semanticstime perf_counter(returns the value in fractional seconds of performance counterdefined as clock with the highest available resolution to measure short duration it includes time elapsed during sleep states and is system-wide time process_time(returns the value in fractional seconds of the sum of the system and user cpu time of the current process it does not include time elapsed during sleepand is process-wide by definition for both of these callsthe reference point of the returned value is undefinedso that only the difference between the results of consecutive calls is valid the perf_counter call can be thought of as wall timeand as of python is used by default for benchmarking in the timeit module discussed aheadprocess_time gives cpu time portably the time clock call is still usable on windows todayas shown in this book it is documented as being deprecated in ' manualsbut issues no warning when used there --meaning it may or may not become officially deprecated in later releases if neededyou can detect python or later with code like thiswhich opted to not use for the sake of brevity and timer comparabilityif sys version_info[ > and sys version_info[ > timer time perf_counter or process_time elsetimer time clock if sys platform[: ='winelse time time alternativelythe following code would also add portability and insulate you from future deprecationsthough it depends on exception topics we haven' studied in full timing iteration alternatives