Description
f = profile f -- replace a global function
f by a profiled version.
The new function is the same as the old one, except that when the new function is run, it will record the number of times it is called and the total execution time. Use the command
profileSummary to display the data recorded so far.
i1 : R = ZZ/31[x]
o1 = R
o1 : PolynomialRing
|
i2 : f = (x^110+1)*(x^13+1)
123 110 13
o2 = x + x + x + 1
o2 : R
|
i3 : time factor f
-- used 0.00267792 seconds
2 2 2 2 2 4 3 2 4 3 2 4 3 2 10 8 6 4 2 10 8 6 4 2 10 8 6 4 2 10 8 6 4 2 10 8 6 4 2 10 8 6 4 2 10 8 6 4 2 10 8 6 4 2 10 8 6 4 2 10 8 6 4 2
o3 = (x + 1)(x - 15)(x + 8)(x + 4)(x + 2)(x + 1)(x - 4x + 11x - 4x + 1)(x - 6x - 2x - 6x + 1)(x + 9x - 4x + 9x + 1)(x - 5x - 8x - 4x - 13x + 1)(x - 9x + 15x - 2x + 10x + 1)(x - 10x - x - x + 9x + 1)(x - 11x - 8x - 4x + 11x + 1)(x - 13x - 4x - 8x - 5x + 1)(x + 13x - 2x + 15x + 5x + 1)(x + 11x - 4x - 8x - 11x + 1)(x + 10x - 2x + 15x - 9x + 1)(x + 9x - x - x - 10x + 1)(x + 5x + 15x - 2x + 13x + 1)
o3 : Expression of class Product
|
i4 : g = () -> factor f
o4 = g
o4 : FunctionClosure
|
i5 : g = profile g
o5 = g
o5 : FunctionClosure
|
i6 : h = profile("h", () -> factor f)
o6 = h
o6 : FunctionClosure
|
i7 : for i to 10 do (g();h();h())
|
i8 : profileSummary
g: 11 times, used .0248609 seconds
h: 22 times, used .0494306 seconds
|