From a67580c777d0f026d6e8f7ee79b56a1d194ff051 Mon Sep 17 00:00:00 2001 From: rask24 Date: Tue, 20 Feb 2024 14:35:25 +0900 Subject: [PATCH] fix performance test --- Gemfile | 1 + Gemfile.lock | 2 ++ test/e2e/performance.rb | 11 +++++------ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 20116d7..335e5d3 100644 --- a/Gemfile +++ b/Gemfile @@ -5,3 +5,4 @@ source "https://rubygems.org" gem "rspec" gem "open3" gem "rubocop-shopify", require: false +gem "descriptive_statistics" diff --git a/Gemfile.lock b/Gemfile.lock index a83eca6..78753fc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -50,6 +51,7 @@ PLATFORMS ruby DEPENDENCIES + descriptive_statistics open3 rspec rubocop-shopify diff --git a/test/e2e/performance.rb b/test/e2e/performance.rb index 9fcf7f3..e7d70d9 100644 --- a/test/e2e/performance.rb +++ b/test/e2e/performance.rb @@ -1,11 +1,14 @@ # 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 @@ -13,8 +16,4 @@ 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