Skip to content

Instantly share code, notes, and snippets.

@RX14

RX14/bench.cr Secret

Created June 9, 2017 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RX14/31840240d9a3b751b5f327b16eaee652 to your computer and use it in GitHub Desktop.
Save RX14/31840240d9a3b751b5f327b16eaee652 to your computer and use it in GitHub Desktop.
channel = Channel(Int32).new
spawn do
start = Time.now
100_000_000.times do
channel.send 1
channel.receive
end
p 100_000_000 / (Time.now - start).total_seconds
end
spawn do
start = Time.now
100_000_000.times do
channel.receive
channel.send 1
end
p 100_000_000 / (Time.now - start).total_seconds
end
Fiber.yield
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment