Open haraldschilly opened 7 years ago
Can somebody also come up with an example? I wonder if this "just works" already in our Jupyter notebooks, and also when using a kernel through a Sage worksheet?
Here is a contrived example, running in Anaconda Python 3 on CoCalc. It's basically the line_profiler:
def f(x):
return 2*x +1
def g(a, n):
b = f(a)
for i in range(n):
b = f(a) + f(b)
return b
---
%load_ext line_profiler
---
%lprun -f g g(5, 100)
---
%lprun -f f g(5, 100) # notice, 200 hits for f, when calling g(5,100)
It works in console version of sage. It is also mentioned in the Sage documentation on profiling.
Supposedly a line profiler, there is also
%prun
, though.Ref: https://twitter.com/vit_tucek/status/877084507119247360