Skip to content

Commit

Permalink
add review.rb (#49)
Browse files Browse the repository at this point in the history
Co-authored-by: reasuke <[email protected]>
  • Loading branch information
rask24 and reasuke committed Feb 27, 2024
1 parent 73a6123 commit 412c874
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
23 changes: 23 additions & 0 deletions test/e2e/review.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

require_relative "./helper/command_helper"
require "descriptive_statistics"

size = 100
iters = 20

results = []

iters.times do
input = (-10000..10000).to_a.sample(size).map(&:to_s)
stdout, _stderr, _status = execute_push_swap(*input)
count = stdout.split("\n").count

results << count
stdout, _stderr, _status = execute_checker(*input)
print "#{count}, #{stdout}"
end

puts "max: #{results.max}"
puts "min: #{results.min}"
puts "average: #{results.mean}"
18 changes: 9 additions & 9 deletions test/e2e/spec/checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
require_relative "../helper/command_helper"

describe("Performance test for push_swap") do
[1, 2, 3, 4, 5, 10, 50, 100, 200, 500, 1000].each do |size|
it "measures operations for random input of size #{size}" do
input = (-10000..10000).to_a.sample(size).map(&:to_s)
_stdout, _stderr, status = execute_push_swap(*input)
expect(status.exitstatus).to(eq(0))
size = 100

stdout, _stderr, status = execute_checker(*input)
expect(status.exitstatus).to(eq(0))
expect(stdout).to(eq("OK\n"))
end
it "measures operations for random input of size #{size}" do
input = (-10000..10000).to_a.sample(size).map(&:to_s)
_stdout, _stderr, status = execute_push_swap(*input)
expect(status.exitstatus).to(eq(0))

stdout, _stderr, status = execute_checker(*input)
expect(status.exitstatus).to(eq(0))
expect(stdout).to(eq("OK\n"))
end
end

0 comments on commit 412c874

Please sign in to comment.