Skip to content

Commit

Permalink
Add benchmark specs
Browse files Browse the repository at this point in the history
  • Loading branch information
corny committed Jun 13, 2020
1 parent 57af59a commit 994ba6f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/benchmark_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

require "spec_helper"

describe "Performance testing" do

let(:disposable_domain) { ValidEmail2.disposable_emails.first }

it "lookup timing" do
# preload disposable emails
list = ValidEmail2.disposable_emails
address = ValidEmail2::Address.new("test@example.com")

expect { address.send(:domain_is_in?, list) }.to perform_under(0.0001).sample(10).times
end

end
9 changes: 9 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
$:.unshift File.expand_path("../lib",__FILE__)
require "valid_email2"

# Include and configure benchmark
require 'rspec-benchmark'
RSpec.configure do |config|
config.include RSpec::Benchmark::Matchers
end
RSpec::Benchmark.configure do |config|
config.disable_gc = true
end

class TestModel
include ActiveModel::Validations

Expand Down
1 change: 1 addition & 0 deletions valid_email2.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 2.0"
spec.add_development_dependency "rake", "~> 12.3.3"
spec.add_development_dependency "rspec", "~> 3.5.0"
spec.add_development_dependency "rspec-benchmark", "~> 0.6"
spec.add_development_dependency "pry"
spec.add_runtime_dependency "mail", "~> 2.5"
spec.add_runtime_dependency "activemodel", ">= 3.2"
Expand Down

0 comments on commit 994ba6f

Please sign in to comment.