Opened 10 years ago

Closed 10 years ago

#11557 closed enhancement (fixed)

Machine-readable timeit() output

Reported by: vbraun Owned by: tbd
Priority: major Milestone: sage-4.7.2
Component: performance Keywords:
Cc: Merged in: sage-4.7.2.alpha1
Authors: Volker Braun Reviewers: John Palmieri
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by vbraun)

This patch implements an optional seconds=True keyword argument to return the number of seconds as a floating-point number instead of printing something on the screen:

sage: t = timeit("print 'Hi'", seconds=True)
sage: t
6.7710876464843747e-07

This makes it much easier to make plots for timing information.

Apply trac_11557_timeit_in_seconds.patch, trac_11557-referee.patch

Attachments (2)

trac_11557_timeit_in_seconds.patch (11.2 KB) - added by vbraun 10 years ago.
Initial patch
trac_11557-referee.patch (3.3 KB) - added by jhpalmieri 10 years ago.
apply on top of other patch

Download all attachments as: .zip

Change History (9)

Changed 10 years ago by vbraun

Initial patch

comment:1 Changed 10 years ago by vbraun

  • Status changed from new to needs_review

Also, documentation of sage.misc.sage_timeit is cleaned up and added to reference manual.

comment:2 Changed 10 years ago by jhpalmieri

Looks good overall.

A few comments:

  • line 42 in sage_timeit.py: "blah"?
  • line 99: "evaluate" should be capitalized.
  • should sage_timeit_class.pyx be in the reference manual?
  • in sage_timeit_class.pyx, do you understand the parenthetical remark in "The preparser is on by default (if it is on)"? Do you have ideas about how to clarify it?

I'm attaching a referee patch to address the first three of these.

Changed 10 years ago by jhpalmieri

apply on top of other patch

comment:3 Changed 10 years ago by vbraun

I thought about adding sage_timeit_class.pyx to the manual but decided against it. Its just some Cython nuts and bolts for the Python timeit command. But then I don't have a strong opinion on it.

As for the "(if it is on)", I think it refers to the possibility to turn the preparser off in the Sage session via preparser(False).

comment:4 Changed 10 years ago by jhpalmieri

  • Reviewers set to John Palmieri

The advantage of adding sage_timeit_class.pyx to the manual is that its focus is to document the timeit command. You can extract some of the same information from the page for sage_timeit.py, but I think it's a good idea to include both pages.

I'm happy with the combination of the two patches. How about you?

comment:5 Changed 10 years ago by vbraun

  • Description modified (diff)
  • Status changed from needs_review to positive_review

I'm happy with them, too. I take it you mean "positive review" by that :-)

comment:6 Changed 10 years ago by kcrisman

Hey, this is a nice ticket.

I don't want to hold it up, but I am wondering whether you think it would be worth having a new ticket to include an example of what you mean by "This makes it much easier to make plots for timing information."? If this is now in the reference manual, then having a common use case - perhaps even toward the top of the module, or in timeit?, could be useful.

Anyway, just a thought if you have an easy # random example, not here, of course.

comment:7 Changed 10 years ago by jdemeyer

  • Merged in set to sage-4.7.2.alpha1
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.