Opened 12 months ago

Closed 6 months ago

#31368 closed defect (fixed)

time in *.sage file

Reported by: hemmecke Owned by:
Priority: major Milestone: sage-9.4
Component: misc Keywords:
Cc: Merged in:
Authors: John Palmieri Reviewers: Kwankyu Lee
Report Upstream: N/A Work issues:
Branch: ca407e4 (Commits, GitHub, GitLab) Commit: ca407e4f74f3fa30c9f64e796ff6496400082adc
Dependencies: Stopgaps:

Status badges


In Sage 9.1 or 9.2, I can type this and get some timing output.

sage: time a=1+2
CPU times: user 5 µs, sys: 2 µs, total: 7 µs
Wall time: 7.63 µs

However, when I put

time a=1+2

into footime.sage and then run

sage footime.sage

I see the following output:

Traceback (most recent call last):
  File "", line 7, in <module>
    __time__=misc.cputime(); __wall__=misc.walltime(); a = _sage_const_1 +_sage_const_2 ; print("Time: CPU %.2f s, Wall: %.2f s"%(misc.cputime(__time__), misc.walltime(__wall__)))
NameError: name 'misc' is not defined

There is a generated with the following content.

# This file was *autogenerated* from the file footime.sage
from sage.all_cmdline import *   # import sage library

_sage_const_1 = Integer(1); _sage_const_2 = Integer(2)
__time__=misc.cputime(); __wall__=misc.walltime(); a = _sage_const_1 +_sage_const_2 ; print("Time: CPU %.2f s, Wall: %.2f s"%(misc.cputime(__time__), misc.walltime(__wall__)))

Change History (10)

comment:1 Changed 12 months ago by jhpalmieri

  • Branch set to u/jhpalmieri/preparse-time

comment:2 Changed 12 months ago by jhpalmieri

  • Authors set to John Palmieri
  • Commit set to 3c626b8d0155af6d740cc340aae94546ee013f16
  • Status changed from new to needs_review

I think this should fix it.

New commits:

3c626b8trac 31368: fix preparsing of "time"

comment:3 Changed 10 months ago by mkoeppe

  • Milestone changed from sage-9.3 to sage-9.4

Sage development has entered the release candidate phase for 9.3. Setting a new milestone for this ticket based on a cursory review of ticket status, priority, and last modification date.

comment:4 Changed 10 months ago by klee

You can use cputime() and walltime() instead of sage.misc.misc.cputime() and sage.misc.misc.walltime(). They are imported by from sage.all_cmdline import *

comment:5 Changed 10 months ago by klee

  • Reviewers set to Kwankyu Lee

comment:6 Changed 10 months ago by git

  • Commit changed from 3c626b8d0155af6d740cc340aae94546ee013f16 to ca407e4f74f3fa30c9f64e796ff6496400082adc

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

55b4364trac 31368: fix preparsing of "time"
ca407e4trac 31368: change imports from 'sage.misc.misc.cputime' to 'cputime', etc.

comment:7 Changed 10 months ago by jhpalmieri

Okay, done.

comment:8 Changed 9 months ago by klee

  • Status changed from needs_review to positive_review

comment:9 Changed 6 months ago by mkoeppe

  • Priority changed from minor to major

Promoting the oldest 5 positively reviewed tickets to "major"

comment:10 Changed 6 months ago by vbraun

  • Branch changed from u/jhpalmieri/preparse-time to ca407e4f74f3fa30c9f64e796ff6496400082adc
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.