Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time magic: shorten unnecessary output on windows #2961

Merged
merged 1 commit into from Mar 10, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions IPython/core/magics/execution.py
Expand Up @@ -948,8 +948,10 @@ def time(self,line='', cell=None, local_ns=None):
cpu_user = end[0]-st[0]
cpu_sys = end[1]-st[1]
cpu_tot = cpu_user+cpu_sys
print "CPU times: user %s, sys: %s, total: %s" % \
(_format_time(cpu_user),_format_time(cpu_sys),_format_time(cpu_tot))
# On windows cpu_sys is always zero, so no new information to the next print
if sys.platform != 'win32':
print "CPU times: user %s, sys: %s, total: %s" % \
(_format_time(cpu_user),_format_time(cpu_sys),_format_time(cpu_tot))
print "Wall time: %s" % _format_time(wall_time)
if tc > tc_min:
print "Compiler : %s" % _format_time(tc)
Expand Down
12 changes: 10 additions & 2 deletions IPython/core/tests/test_magic.py
Expand Up @@ -283,16 +283,24 @@ def test_tb_syntaxerror():
def test_time():
ip = get_ipython()

with tt.AssertPrints("CPU times: user "):
with tt.AssertPrints("Wall time: "):
ip.run_cell("%time None")

ip.run_cell("def f(kmjy):\n"
" %time print (2*kmjy)")

with tt.AssertPrints("CPU times: user "):
with tt.AssertPrints("Wall time: "):
with tt.AssertPrints("hihi", suppress=False):
ip.run_cell("f('hi')")


@dec.skip_win32
def test_time2():
ip = get_ipython()

with tt.AssertPrints("CPU times: user "):
ip.run_cell("%time None")

def test_doctest_mode():
"Toggle doctest_mode twice, it should be a no-op and run without error"
_ip.magic('doctest_mode')
Expand Down