let' look at straightforward way to benchmark an algorithm' runtime performance this can be done by simply timing how long the algorithm takes to complete given various input sizes as we mentioned earlierthis way of measuring runtime performance is dependent on the hardware that it is run on obviously faster processors will give better resultshoweverthe relative growth rates as we increase the input size will retain characteristics of the algorithm itself rather than the hardware it is run on the absolute time values will differ between hardware (and softwareplatformshowevertheir relative growth will still be bound by the time complexity of the algorithm let' take simple example of nested loop it should be fairly obvious that the time complexity of this algorithm is ( since for each iterations in the outer loop there are also iterations in the inter loop for exampleour simple nested for loop consists of simple statement executed on the inner loopdef nest( )for in range( )for in range( ) + the following code is simple test function that runs the nest function with increasing values of with each iteration we calculate the time this function takes to complete using the timeit timeit function the timeit functionin this exampletakes three argumentsa string representation of the function to be timeda setup function that imports the nest functionand an int parameter that indicates the number of times to execute the main statement since we are interested in the time the nest function takes to complete relative to the input sizenit is sufficientfor our purposesto call the nest function once on each iteration the following function returns list of the calculated runtimes for each value of nimport timeit def test ( )ls=[for in range( ) =timeit timeit("nest(str( +")"setup="from __main__ import nest"number ls append(treturn ls in the following code we run the test function and graph the resultstogether with the appropriately scaled function for comparisonrepresented by the dashed lineimport matplotlib pyplot as plt = plt plot(test ( )plt plot([ * / for in range( )]