Skip to content

Commit

Permalink
fix performance test
Browse files Browse the repository at this point in the history
  • Loading branch information
rask24 committed Feb 20, 2024
1 parent 0397d60 commit a67580c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ source "https://rubygems.org"
gem "rspec"
gem "open3"
gem "rubocop-shopify", require: false
gem "descriptive_statistics"
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
descriptive_statistics (2.5.1)
diff-lcs (1.5.1)
json (2.7.1)
language_server-protocol (3.17.0.3)
Expand Down Expand Up @@ -50,6 +51,7 @@ PLATFORMS
ruby

DEPENDENCIES
descriptive_statistics
open3
rspec
rubocop-shopify
Expand Down
11 changes: 5 additions & 6 deletions test/e2e/performance.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# frozen_string_literal: true

require_relative "helper/command_helper"
require "descriptive_statistics"

size = 500
iters = 50

results = []

100.times do
iters.times do
input = (0...size).to_a.shuffle.map(&:to_s)
stdout, _stderr, _status = execute_push_swap(*input)
results << stdout.split("\n").count

print "\e[32m.\e[0m"
end

max_operations = results.max
min_operations = results.min
average_operations = results.sum / results.size.to_f

puts "\nFor size #{size}: Max: #{max_operations}, Min: #{min_operations}, Average: #{average_operations}"
puts "\nFor size #{size}: Max: #{results.max}, Min: #{results.min}, Average: #{results.mean}, SD: #{results.standard_deviation.round(2)}" # rubocop:disable Layout/LineLength

0 comments on commit a67580c

Please sign in to comment.