Sha256: 78c538a666b8211807afca29ae11f94d7cf7783c63060d682c757961f642f9df

Contents?: true

Size: 1.93 KB

Versions: 42

Compression:

Stored size: 1.93 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

puts ""
puts "Vanilla Rack server started in background thread on localhost:7011"
puts "Instrumented Rack server started in background thread on localhost:7012"
puts ""
puts "Waiting on successful announce to host agent..."
puts ""

while !::Instana.agent.ready? do
  sleep 2
end

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

42 entries across 42 versions & 1 rubygems

Version Path
instana-1.193.4 benchmarks/rack_vanilla_vs_traced.rb
instana-1.193.3 benchmarks/rack_vanilla_vs_traced.rb
instana-1.193.3.pre1 benchmarks/rack_vanilla_vs_traced.rb
instana-1.193.2 benchmarks/rack_vanilla_vs_traced.rb
instana-1.192.1 benchmarks/rack_vanilla_vs_traced.rb
instana-1.192.0 benchmarks/rack_vanilla_vs_traced.rb
instana-1.13.0 benchmarks/rack_vanilla_vs_traced.rb
instana-1.12.0 benchmarks/rack_vanilla_vs_traced.rb
instana-1.11.8-java benchmarks/rack_vanilla_vs_traced.rb
instana-1.11.8 benchmarks/rack_vanilla_vs_traced.rb
instana-1.11.7 benchmarks/rack_vanilla_vs_traced.rb
instana-1.11.6 benchmarks/rack_vanilla_vs_traced.rb
instana-1.11.6-java benchmarks/rack_vanilla_vs_traced.rb
instana-1.11.5 benchmarks/rack_vanilla_vs_traced.rb
instana-1.11.5-java benchmarks/rack_vanilla_vs_traced.rb
instana-1.11.4-java benchmarks/rack_vanilla_vs_traced.rb
instana-1.11.4 benchmarks/rack_vanilla_vs_traced.rb
instana-1.11.3-java benchmarks/rack_vanilla_vs_traced.rb
instana-1.11.3 benchmarks/rack_vanilla_vs_traced.rb
instana-1.11.2-java benchmarks/rack_vanilla_vs_traced.rb