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

Backport PR #13050 on branch 7.x (Make Ipython.utils.timing work with jupyterlite) #13070

Merged
Merged
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
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