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 consumed by gevent scheduling #1984

Open
xpf629629 opened this issue Aug 7, 2023 · 0 comments
Open

Time consumed by gevent scheduling #1984

xpf629629 opened this issue Aug 7, 2023 · 0 comments

Comments

@xpf629629
Copy link

import time
import gevent
n = 1000000
def worker():
    for _ in range(n):
        gevent.sleep(0)

start_time = time.process_time_ns()

greenlet = gevent.spawn(worker)

for _ in range(n):
    gevent.sleep(0)

end_time = time.process_time_ns()

switch_time = (end_time - start_time)/(2*n)
print("Context switch time:", switch_time, "ns")

Is there a better way to measure loop scheduling time? Or does gevent itself provide this metric?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant