Skip to content

Commit

Permalink
Merge pull request #13070 from meeseeksmachine/auto-backport-of-pr-13…
Browse files Browse the repository at this point in the history
…050-on-7.x

Backport PR #13050 on branch 7.x (Make Ipython.utils.timing work with jupyterlite)
  • Loading branch information
Carreau committed Jul 31, 2021
2 parents f34978f + 78bbe19 commit 3e0a411
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 3e0a411

Please sign in to comment.