cProfile is a
C extension introduced in Python 2.5. It can be used for deterministic profiling. Deterministic profiling means that the time measurements obtained are precise and no sampling is used. This contrasts with statistical profiling, where measurements come from random samples. We will profile a small NumPy program using
cProfile, which transposes an array with random values.
Again, we require code to profile:
transpose()function to create an array with random values and transpose it:
def transpose(n): random_values = np.random.random((n, n)) return random_values.T
The complete ...