Sha256: 3bf7832c003b39659b1a498435c90fec5907b382770f52046dd5aa1fb6de5f77

Contents?: true

Size: 1.78 KB

Versions: 17

Compression:

Stored size: 1.78 KB

Contents

require "bundler"

require 'rack'
require 'rack/builder'
require 'rack/handler/puma'
require 'net/http'
require "benchmark"
require "cgi"
Bundler.require(:default)
require "instana/rack"

Thread.new do
  app = Rack::Builder.new {
    map "/" do
      run Proc.new {
        [200, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"scene!\"]"]]
      }
    end
    map "/error" do
      run Proc.new {
        [500, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"error!\"]"]]
      }
    end
  }

  Rack::Handler::Puma.run(app, {:Host => '127.0.0.1', :Port => 7011})
end

Thread.new do
  app = Rack::Builder.new {
    use ::Instana::Rack
    map "/" do
      run Proc.new {
        [200, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"scene!\"]"]]
      }
    end
    map "/error" do
      run Proc.new {
        [500, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"error!\"]"]]
      }
    end
  }

  Rack::Handler::Puma.run(app, {:Host => '127.0.0.1', :Port => 7012})
end

sleep(2)
puts "Rack server started in background thread on localhost:7011"
puts "Sleeping for 10 to allow announce"
sleep(10)


puts "Starting benchmarks"
Benchmark.bm do |x|

  uri = URI.parse("http://127.0.0.1:7011/")
  ::Net::HTTP.start(uri.host, uri.port) do |hc|
    x.report("vanilla") {
      1_000.times {
        req = Net::HTTP::Get.new(uri.request_uri)
        hc.request(req)
      }
    }
  end

  uri = URI.parse("http://127.0.0.1:7012/")
  ::Net::HTTP.start(uri.host, uri.port) do |hc|
    x.report("traced ") {
      1_000.times {
        ::Instana.tracer.start_or_continue_trace(:rack_call) do
          req = Net::HTTP::Get.new(uri.request_uri)
          hc.request(req)
        end
      }
    }
  end
end


sleep 10

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
instana-1.10.2-java benchmarks/rack_vanilla_vs_traced.rb
instana-1.10.2 benchmarks/rack_vanilla_vs_traced.rb
instana-1.10.1-java benchmarks/rack_vanilla_vs_traced.rb
instana-1.10.1 benchmarks/rack_vanilla_vs_traced.rb
instana-1.10.0 benchmarks/rack_vanilla_vs_traced.rb
instana-1.10.0.slimfast benchmarks/rack_vanilla_vs_traced.rb
instana-1.9.7 benchmarks/rack_vanilla_vs_traced.rb
instana-1.9.6 benchmarks/rack_vanilla_vs_traced.rb
instana-1.9.5 benchmarks/rack_vanilla_vs_traced.rb
instana-1.9.4 benchmarks/rack_vanilla_vs_traced.rb
instana-1.9.3 benchmarks/rack_vanilla_vs_traced.rb
instana-1.9.2 benchmarks/rack_vanilla_vs_traced.rb
instana-1.9.1 benchmarks/rack_vanilla_vs_traced.rb
instana-1.9.0 benchmarks/rack_vanilla_vs_traced.rb
instana-1.9.0.daftrabbit benchmarks/rack_vanilla_vs_traced.rb
instana-1.8.3 benchmarks/rack_vanilla_vs_traced.rb
instana-1.9.0.sillyrabbit benchmarks/rack_vanilla_vs_traced.rb