Skip to content

Instantly share code, notes, and snippets.

@luislavena
Last active March 28, 2017 07:00
Show Gist options
  • Save luislavena/2fc0a7b0babdf776f1da to your computer and use it in GitHub Desktop.
Save luislavena/2fc0a7b0babdf776f1da to your computer and use it in GitHub Desktop.

Crystal benchmark (nightly vs new-fibers)

This benchmark compares the performance of new fibers implementation vs current (PCL backed one).

  • Code was compiled with --release flag
  • Benchmarks were performed on same computer (localhost)

Benchmarks

Simple HTTP Hello (direct HTTP::Server)

require "http/server"

server = HTTP::Server.new(9292) do |request|
  HTTP::Response.ok "text/html", "Hello World!"
end

Signal::INT.trap {
  server.close
  exit
}

server.listen
Crystal req/s latency
0.10.0 [dcdad46] 99168.95 1.01ms
new-fibers [e338cb1] 119483.80 841.39us

Beryl (Hello World)

require "beryl"

class HelloAction < Beryl::Action
  def call(params)
    HTTP::Response.ok "text/html", "Hello World!"
  end
end

class HelloRouter < Beryl::Router
  routing do
    get "/", HelloAction
  end
end

server = HTTP::Server.new(9292, HelloRouter.new)

Signal::INT.trap {
  server.close
  exit
}

server.listen
Crystal req/s latency
0.10.0 [dcdad46] 70528.02 1.41ms
new-fibers [e338cb1] 75957.72 1.32ms

Hardware

The following hardware was used for these benchmarks:

  • Ubuntu 15.10 64-bit (kernel: 4.2.0-23-generic)
  • Dell XPS 13 (9343, QHD, Developer Edition)
  • Intel® Core™ i7-5500U CPU @ 2.40GHz × 4
  • 8GB RAM
  • 256GB SSD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment