Opened 22 months ago

Closed 17 months ago

## #31368 closed defect (fixed)

# time in *.sage file

Reported by: | RalfHemmecke | 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: |

### Description

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 "footime.sage.py", 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 `footime.sage.py`

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 22 months ago by

Branch: | → u/jhpalmieri/preparse-time |
---|

### comment:2 Changed 22 months ago by

Authors: | → John Palmieri |
---|---|

Commit: | → 3c626b8d0155af6d740cc340aae94546ee013f16 |

Status: | new → needs_review |

### comment:3 Changed 21 months ago by

Milestone: | sage-9.3 → 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 20 months ago by

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 20 months ago by

Reviewers: | → Kwankyu Lee |
---|

### comment:6 Changed 20 months ago by

Commit: | 3c626b8d0155af6d740cc340aae94546ee013f16 → ca407e4f74f3fa30c9f64e796ff6496400082adc |
---|

### comment:8 Changed 20 months ago by

Status: | needs_review → positive_review |
---|

### comment:9 Changed 17 months ago by

Priority: | minor → major |
---|

Promoting the oldest 5 positively reviewed tickets to "major"

### comment:10 Changed 17 months ago by

Branch: | u/jhpalmieri/preparse-time → ca407e4f74f3fa30c9f64e796ff6496400082adc |
---|---|

Resolution: | → fixed |

Status: | positive_review → closed |

**Note:**See TracTickets for help on using tickets.

I think this should fix it.

New commits:

`trac 31368: fix preparsing of "time"`