ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 31 Oct 2019 21:39:23 +0100how plot time complexity of program for different 'n' using sagemath?https://ask.sagemath.org/question/48564/how-plot-time-complexity-of-program-for-different-n-using-sagemath/I have written a code for graph coloring in sagemath. I'm finding difficult to plot a graph of running time of that program for different node (range of nodes is (1 to infinity or 100000)). Can anyone please tell me how? Thu, 31 Oct 2019 05:59:18 +0100https://ask.sagemath.org/question/48564/how-plot-time-complexity-of-program-for-different-n-using-sagemath/Answer by John Palmieri for <p>I have written a code for graph coloring in sagemath. I'm finding difficult to plot a graph of running time of that program for different node (range of nodes is (1 to infinity or 100000)). Can anyone please tell me how? </p>
https://ask.sagemath.org/question/48564/how-plot-time-complexity-of-program-for-different-n-using-sagemath/?answer=48575#post-id-48575You can assemble the timing data using `sage.misc.sage_timeit` (visit http://doc.sagemath.org/html/en/reference/misc/sage/misc/sage_timeit.html for documentation):
sage: cmd = 'simplicial_complexes.PoincareHomologyThreeSphere().homology()'
sage: a = sage_timeit(cmd, globals())
sage: a # full timing data for the command
5 loops, best of 3: 16.8 ms per loop
sage: a.stats
(25, 3, 3, 16.850331239998013, 'ms')
sage: a = sage_timeit(cmd, globals(), seconds=True)
sage: a # time in seconds for the command
0.016884897239999645Thu, 31 Oct 2019 21:39:23 +0100https://ask.sagemath.org/question/48564/how-plot-time-complexity-of-program-for-different-n-using-sagemath/?answer=48575#post-id-48575