Ask Your Question

Revision history [back]

To measure how much time a command takes, you can use either %time or %timeit:

sage: A = zero_matrix(ZZ,100); B = zero_matrix(ZZ, 100)
sage: for i in range(100):
....:     for j in range(100):
....:         A[i,j] = ZZ.random_element(1000)
....:         B[i,j] = ZZ.random_element(1000)
....: 
sage: %time A*B # this runs the command once and returns its result + timing info
CPU times: user 523 µs, sys: 0 ns, total: 523 µs
Wall time: 525 µs
100 x 100 dense matrix over Integer Ring (use the '.str()' method to see the entries)
sage: %timeit A*B # runs the command multiple times
481 µs ± 763 ns per loop (mean ± std. dev. of 7 runs, 1000 loops each)

For help, evaluate %time? or %timeit?, and see also the relevant Sage Reference manual page.