Skip to content

Commit

Permalink
Add performance check script
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki45 committed Apr 28, 2017
1 parent fab14d9 commit eb081a2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ require "bundler/gem_tasks"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)
task default: :spec
task default: [:spec, :performance_test]

desc 'Check performance'
task :performance_test do
ruby 'scripts/command_performance.rb'
end
1 change: 1 addition & 0 deletions expeditor.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "concurrent-ruby", ">= 1.0.0"
spec.add_runtime_dependency "retryable", "> 1.0"

spec.add_development_dependency "benchmark-ips"
spec.add_development_dependency "bundler"
spec.add_development_dependency "concurrent-ruby-ext", ">= 1.0.0"
spec.add_development_dependency "rake"
Expand Down
25 changes: 25 additions & 0 deletions scripts/command_performance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
$LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
require 'expeditor'

require 'benchmark/ips'

Benchmark.ips do |x|
x.report("simple command") do |i|
executor = Concurrent::ThreadPoolExecutor.new(min_threads: 100, max_threads: 100, max_queue: 100)
service = Expeditor::Service.new(period: 10, non_break_count: 0, threshold: 0.5, sleep: 1, executor: executor)

i.times do
commands = 10000.times.map do
Expeditor::Command.new { 1 }.start
end
command = Expeditor::Command.new(service: service, dependencies: commands) do |*vs|
vs.inject(0, &:+)
end.start
command.get

service.reset_status!
end
end

x.compare!
end

0 comments on commit eb081a2

Please sign in to comment.