Sha256: f776ef04d365ae28a84b0836039d2a1bec1da5b45797fe5be88bbda4a6cfa424

Contents?: true

Size: 1.23 KB

Versions: 13

Compression:

Stored size: 1.23 KB

Contents

require 'support/capybara_app_helper'
require 'benchmark'

EXAMPLE_SIZE = 1000

RSpec.describe 'Benchmark' do
  context 'with tracking' do
    before do
      setup_app(action: :turing) do |tracker|
        tracker.handler :track_all_the_things, { custom_key: 'SomeKey123' }
        tracker.handler :another_handler, { custom_key: 'AnotherKey42' }
      end
    end

    it 'embeds the script tag *lightning fast*' do
      Benchmark.bmbm do |bm|
        bm.report 'render page with inject' do
          EXAMPLE_SIZE.times do
            visit '/'

            expect(page.status_code).to eq(200)
            expect(page.response_headers).to eq('Content-Type' => 'text/html; charset=utf-8', 'Content-Length' => '461684')
          end
        end
      end
    end
  end

  context 'w/o tracking' do
    before do
      setup_app(action: :do_not_track_alan) {}
    end

    it 'is for comparison only' do
      Benchmark.bmbm do |bm|
        bm.report 'render page w/o inject' do
          EXAMPLE_SIZE.times do
            visit '/'

            expect(page.status_code).to eq(200)
            expect(page.response_headers).to eq('Content-Type' => 'text/html; charset=utf-8', 'Content-Length' => '461470')
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rack-tracker-1.13.0 spec/benchmark/tracker_injection_benchmark.rb
rack-tracker-1.12.1 spec/benchmark/tracker_injection_benchmark.rb
rack-tracker-1.12.0 spec/benchmark/tracker_injection_benchmark.rb
rack-tracker-1.11.2 spec/benchmark/tracker_injection_benchmark.rb
rack-tracker-1.11.1 spec/benchmark/tracker_injection_benchmark.rb
rack-tracker-1.11.0 spec/benchmark/tracker_injection_benchmark.rb
rack-tracker-1.10.0 spec/benchmark/tracker_injection_benchmark.rb
rack-tracker-1.9.0 spec/benchmark/tracker_injection_benchmark.rb
rack-tracker-1.8.0 spec/benchmark/tracker_injection_benchmark.rb
rack-tracker-1.7.0 spec/benchmark/tracker_injection_benchmark.rb
rack-tracker-1.6.0 spec/benchmark/tracker_injection_benchmark.rb
rack-tracker-1.5.0 spec/benchmark/tracker_injection_benchmark.rb
rack-tracker-1.4.0 spec/benchmark/tracker_injection_benchmark.rb