Skip to content

Commit

Permalink
Backport PR ipython#13050: Make Ipython.utils.timing work with jupyte…
Browse files Browse the repository at this point in the history
…rlite
  • Loading branch information
Carreau authored and meeseeksmachine committed Jul 31, 2021
1 parent f34978f commit 78bbe19
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion IPython/utils/timing.py
Expand Up @@ -23,6 +23,11 @@
# If possible (Unix), use the resource module instead of time.clock()
try:
import resource
except ImportError:
resource = None

# Some implementations (like jyputerlite) don't have getrusage
if resource is not None and hasattr(resource, "getrusage"):
def clocku():
"""clocku() -> floating point number
Expand Down Expand Up @@ -56,7 +61,9 @@ def clock2():
Similar to clock(), but return a tuple of user/system times."""
return resource.getrusage(resource.RUSAGE_SELF)[:2]
except ImportError:


else:
# There is no distinction of user/system time under windows, so we just use
# time.perff_counter() for everything...
clocku = clocks = clock = time.perf_counter
Expand Down

0 comments on commit 78bbe19

Please sign in to comment.