From 42bde60872e16fe411a9b4458d481854a8bce719 Mon Sep 17 00:00:00 2001 From: rask24 <70057885+rask24@users.noreply.github.com> Date: Tue, 20 Feb 2024 14:36:42 +0900 Subject: [PATCH] fix module (#47) * fix order stack_operations.h * fix module * fix performance test --- Gemfile | 1 + Gemfile.lock | 2 ++ include/checker.h | 5 ++-- include/main.h | 23 ------------------- include/push_swap.h | 7 +----- include/stack_operations.h | 21 +++++++++-------- src/initialization/check_args.c | 3 +-- src/initialization/exit_with_error.c | 3 +-- src/initialization/generate_stack.c | 3 +-- src/main.c | 5 ++-- src/sort/is_sorted_stack.c | 3 +-- src/sort/large_sort/greedy_operation.c | 3 +-- src/sort/large_sort/large_sort.c | 3 +-- src/sort/large_sort/push_b_segmented.c | 3 +-- src/sort/large_sort/set_cost.c | 3 +-- src/sort/large_sort/set_is_target.c | 3 +-- src/sort/large_sort/set_min_cost_opt_method.c | 3 +-- src/sort/micro_sort.c | 3 +-- src/sort/nano_sort.c | 3 +-- src/sort/sort.c | 3 +-- src/stack_operations/do_double_n_operations.c | 4 ++-- src/stack_operations/do_single_n_operations.c | 4 ++-- src/stack_operations/push.c | 4 ++-- src/stack_operations/reverse_rotate.c | 4 ++-- src/stack_operations/rotate.c | 4 ++-- src/stack_operations/swap.c | 4 ++-- src/utils/clear_stack.c | 4 ++-- src/utils/get_content.c | 4 ++-- src/utils/get_first_index.c | 4 ++-- src/utils/get_second_index.c | 4 ++-- src/utils/get_third_index.c | 4 ++-- src/utils/stack_size.c | 4 ++-- test/e2e/performance.rb | 11 ++++----- 33 files changed, 62 insertions(+), 100 deletions(-) delete mode 100644 include/main.h 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/include/checker.h b/include/checker.h index a284326..833a67e 100644 --- a/include/checker.h +++ b/include/checker.h @@ -6,15 +6,14 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/14 10:26:54 by reasuke #+# #+# */ -/* Updated: 2024/02/19 12:11:08 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:19:45 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef CHECKER_H # define CHECKER_H -# include "../libft/libft.h" -# include "types.h" +# include "push_swap.h" void sort_based_on_operation(t_stack **p_a, t_stack **p_b); diff --git a/include/main.h b/include/main.h deleted file mode 100644 index 40c0e0c..0000000 --- a/include/main.h +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* main.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: reasuke +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/02/19 16:23:21 by reasuke #+# #+# */ -/* Updated: 2024/02/19 16:25:20 by reasuke ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef MAIN_H -# define MAIN_H - -# include "push_swap.h" - -int check_args(int argc, char **argv); -t_stack *generate_stack(int argc, char **argv); - -void sort(t_stack **p_a, t_stack **p_b); - -#endif diff --git a/include/push_swap.h b/include/push_swap.h index c55ccee..0efbf41 100644 --- a/include/push_swap.h +++ b/include/push_swap.h @@ -6,7 +6,7 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/10 12:37:54 by reasuke #+# #+# */ -/* Updated: 2024/02/13 12:45:48 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:19:53 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,9 +21,4 @@ # include # include -int check_args(int argc, char **argv); -t_stack *generate_stack(int argc, char **argv); - -void sort(t_stack **p_a, t_stack **p_b); - #endif diff --git a/include/stack_operations.h b/include/stack_operations.h index 40bf5ff..8c75758 100644 --- a/include/stack_operations.h +++ b/include/stack_operations.h @@ -6,7 +6,7 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/11 12:41:01 by reasuke #+# #+# */ -/* Updated: 2024/02/11 12:41:49 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:16:47 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,8 +15,17 @@ # include "push_swap.h" -void operate_sa(t_stack **p_a); +void push_stack(t_stack **p_s1, t_stack **p_s2); +void swap_stack(t_stack **p_stack); +void rotate_stack(t_stack **p_stack); +void reverse_rotate_stack(t_stack **p_stack); + +void do_single_n_operations(t_stack **p_st, int n, + void (*operation)(t_stack **)); +void do_double_n_operations(t_stack **p_a, t_stack **p_b, int n, + void (*operation)(t_stack **, t_stack **)); +void operate_sa(t_stack **p_a); void operate_sb(t_stack **p_b); void operate_ss(t_stack **p_a, t_stack **p_b); void operate_ra(t_stack **p_a); @@ -27,13 +36,5 @@ void operate_rrb(t_stack **p_a); void operate_rrr(t_stack **p_a, t_stack **p_b); void operate_pa(t_stack **p_b, t_stack **p_a); void operate_pb(t_stack **p_a, t_stack **p_b); -void do_single_n_operations(t_stack **p_st, int n, - void (*operation)(t_stack **)); -void do_double_n_operations(t_stack **p_a, t_stack **p_b, int n, - void (*operation)(t_stack **, t_stack **)); -void push_stack(t_stack **p_s1, t_stack **p_s2); -void swap_stack(t_stack **p_stack); -void rotate_stack(t_stack **p_stack); -void reverse_rotate_stack(t_stack **p_stack); #endif diff --git a/src/initialization/check_args.c b/src/initialization/check_args.c index 6d5ca31..890015f 100644 --- a/src/initialization/check_args.c +++ b/src/initialization/check_args.c @@ -6,12 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/11 14:44:55 by reasuke #+# #+# */ -/* Updated: 2024/02/19 12:56:30 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:19:12 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #include "initialization.h" -#include "push_swap.h" static bool _has_not_digit(int argc, char **argv) { diff --git a/src/initialization/exit_with_error.c b/src/initialization/exit_with_error.c index c074c44..c9e7b0b 100644 --- a/src/initialization/exit_with_error.c +++ b/src/initialization/exit_with_error.c @@ -6,12 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/11 14:38:17 by reasuke #+# #+# */ -/* Updated: 2024/02/13 11:46:04 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:19:14 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #include "initialization.h" -#include "push_swap.h" void exit_with_error(void) { diff --git a/src/initialization/generate_stack.c b/src/initialization/generate_stack.c index 37da8cf..76693c3 100644 --- a/src/initialization/generate_stack.c +++ b/src/initialization/generate_stack.c @@ -6,12 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/11 19:04:40 by reasuke #+# #+# */ -/* Updated: 2024/02/14 14:28:39 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:19:17 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #include "initialization.h" -#include "push_swap.h" int *_allocate_int_array(int size_a) { diff --git a/src/main.c b/src/main.c index 2894ed0..bbe18c4 100644 --- a/src/main.c +++ b/src/main.c @@ -6,11 +6,12 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/10 12:37:36 by reasuke #+# #+# */ -/* Updated: 2024/02/19 12:06:15 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:21:01 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ -#include "push_swap.h" +#include "initialization.h" +#include "sort.h" #ifdef LEAK # ifdef __APPLE__ diff --git a/src/sort/is_sorted_stack.c b/src/sort/is_sorted_stack.c index d130a36..9dffb5e 100644 --- a/src/sort/is_sorted_stack.c +++ b/src/sort/is_sorted_stack.c @@ -6,11 +6,10 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/10 18:47:11 by reasuke #+# #+# */ -/* Updated: 2024/02/13 14:01:58 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:18:06 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ -#include "push_swap.h" #include "sort.h" bool is_sorted_stack(t_stack *st) diff --git a/src/sort/large_sort/greedy_operation.c b/src/sort/large_sort/greedy_operation.c index b7914d9..90a3537 100644 --- a/src/sort/large_sort/greedy_operation.c +++ b/src/sort/large_sort/greedy_operation.c @@ -6,12 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/10 10:43:16 by reasuke #+# #+# */ -/* Updated: 2024/02/14 16:40:21 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:17:27 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #include "large_sort.h" -#include "push_swap.h" #include "stack_operations.h" static t_stack *_find_opt_st_b(t_stack **p_b) diff --git a/src/sort/large_sort/large_sort.c b/src/sort/large_sort/large_sort.c index 2052aac..64794c4 100644 --- a/src/sort/large_sort/large_sort.c +++ b/src/sort/large_sort/large_sort.c @@ -6,12 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/22 16:55:10 by reasuke #+# #+# */ -/* Updated: 2024/02/15 12:34:14 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:17:35 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #include "large_sort.h" -#include "push_swap.h" #include "sort.h" #include "stack_operations.h" diff --git a/src/sort/large_sort/push_b_segmented.c b/src/sort/large_sort/push_b_segmented.c index ab153ed..1d3b6cb 100644 --- a/src/sort/large_sort/push_b_segmented.c +++ b/src/sort/large_sort/push_b_segmented.c @@ -6,12 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/11 22:57:28 by reasuke #+# #+# */ -/* Updated: 2024/02/14 14:31:29 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:17:46 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #include "large_sort.h" -#include "push_swap.h" #include "stack_operations.h" static int _calc_segment_id(int target, int n, int segs) diff --git a/src/sort/large_sort/set_cost.c b/src/sort/large_sort/set_cost.c index 3050838..46e6495 100644 --- a/src/sort/large_sort/set_cost.c +++ b/src/sort/large_sort/set_cost.c @@ -6,12 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/08 12:17:33 by reasuke #+# #+# */ -/* Updated: 2024/02/14 14:15:57 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:17:50 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #include "large_sort.h" -#include "push_swap.h" static int _calc_insertion_threshold(t_stack **p_a, t_stack *st_b) { diff --git a/src/sort/large_sort/set_is_target.c b/src/sort/large_sort/set_is_target.c index d26ebd7..32e7a51 100644 --- a/src/sort/large_sort/set_is_target.c +++ b/src/sort/large_sort/set_is_target.c @@ -6,12 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/14 14:44:38 by reasuke #+# #+# */ -/* Updated: 2024/02/14 16:42:11 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:17:53 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #include "large_sort.h" -#include "push_swap.h" static int _calc_max_segment(t_stack *st_b) { diff --git a/src/sort/large_sort/set_min_cost_opt_method.c b/src/sort/large_sort/set_min_cost_opt_method.c index 4b88be0..d291396 100644 --- a/src/sort/large_sort/set_min_cost_opt_method.c +++ b/src/sort/large_sort/set_min_cost_opt_method.c @@ -6,12 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/09 10:23:28 by reasuke #+# #+# */ -/* Updated: 2024/02/14 15:44:15 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:18:02 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #include "large_sort.h" -#include "push_swap.h" static int _calc_cost(t_stack *st_b, t_method method) { diff --git a/src/sort/micro_sort.c b/src/sort/micro_sort.c index 60d0283..80f963f 100644 --- a/src/sort/micro_sort.c +++ b/src/sort/micro_sort.c @@ -6,11 +6,10 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/15 16:32:27 by reasuke #+# #+# */ -/* Updated: 2024/02/13 15:38:56 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:18:10 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ -#include "push_swap.h" #include "sort.h" #include "stack_operations.h" diff --git a/src/sort/nano_sort.c b/src/sort/nano_sort.c index 14c14ca..ea9a2bd 100644 --- a/src/sort/nano_sort.c +++ b/src/sort/nano_sort.c @@ -6,11 +6,10 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/12 15:58:22 by reasuke #+# #+# */ -/* Updated: 2024/02/11 12:54:19 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:18:22 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ -#include "push_swap.h" #include "sort.h" #include "stack_operations.h" diff --git a/src/sort/sort.c b/src/sort/sort.c index ff7cf8f..4e3e151 100644 --- a/src/sort/sort.c +++ b/src/sort/sort.c @@ -6,11 +6,10 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/15 15:10:35 by reasuke #+# #+# */ -/* Updated: 2024/02/11 12:54:21 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:18:25 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ -#include "push_swap.h" #include "sort.h" void sort(t_stack **p_a, t_stack **p_b) diff --git a/src/stack_operations/do_double_n_operations.c b/src/stack_operations/do_double_n_operations.c index 8dcf852..2956ba0 100644 --- a/src/stack_operations/do_double_n_operations.c +++ b/src/stack_operations/do_double_n_operations.c @@ -6,11 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/10 19:22:50 by reasuke #+# #+# */ -/* Updated: 2024/02/10 19:29:43 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:15:32 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ -#include "push_swap.h" +#include "stack_operations.h" void do_double_n_operations(t_stack **p_a, t_stack **p_b, int n, void (*operation)(t_stack **, t_stack **)) diff --git a/src/stack_operations/do_single_n_operations.c b/src/stack_operations/do_single_n_operations.c index 17d6047..009266a 100644 --- a/src/stack_operations/do_single_n_operations.c +++ b/src/stack_operations/do_single_n_operations.c @@ -6,11 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/10 19:22:26 by reasuke #+# #+# */ -/* Updated: 2024/02/10 19:29:08 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:15:35 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ -#include "push_swap.h" +#include "stack_operations.h" void do_single_n_operations(t_stack **p_st, int n, void (*operation)(t_stack **)) diff --git a/src/stack_operations/push.c b/src/stack_operations/push.c index a58bbaa..cae26a5 100644 --- a/src/stack_operations/push.c +++ b/src/stack_operations/push.c @@ -6,11 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/15 15:56:53 by reasuke #+# #+# */ -/* Updated: 2024/02/07 15:05:10 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:15:37 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ -#include "push_swap.h" +#include "stack_operations.h" void push_stack(t_stack **p_s1, t_stack **p_s2) { diff --git a/src/stack_operations/reverse_rotate.c b/src/stack_operations/reverse_rotate.c index 0db9f93..5e4ed49 100644 --- a/src/stack_operations/reverse_rotate.c +++ b/src/stack_operations/reverse_rotate.c @@ -6,11 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/23 17:18:15 by reasuke #+# #+# */ -/* Updated: 2024/02/07 15:04:58 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:15:40 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ -#include "push_swap.h" +#include "stack_operations.h" void reverse_rotate_stack(t_stack **p_stack) { diff --git a/src/stack_operations/rotate.c b/src/stack_operations/rotate.c index eff3e01..c9d6f0d 100644 --- a/src/stack_operations/rotate.c +++ b/src/stack_operations/rotate.c @@ -6,11 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/15 14:05:46 by reasuke #+# #+# */ -/* Updated: 2024/02/07 15:05:17 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:15:43 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ -#include "push_swap.h" +#include "stack_operations.h" void rotate_stack(t_stack **p_stack) { diff --git a/src/stack_operations/swap.c b/src/stack_operations/swap.c index 042c331..6157b3f 100644 --- a/src/stack_operations/swap.c +++ b/src/stack_operations/swap.c @@ -6,11 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/15 13:28:54 by reasuke #+# #+# */ -/* Updated: 2024/02/07 15:05:21 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:15:51 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ -#include "push_swap.h" +#include "stack_operations.h" void swap_stack(t_stack **p_stack) { diff --git a/src/utils/clear_stack.c b/src/utils/clear_stack.c index dce9e85..0ce9d2f 100644 --- a/src/utils/clear_stack.c +++ b/src/utils/clear_stack.c @@ -6,11 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/23 15:46:24 by reasuke #+# #+# */ -/* Updated: 2024/02/07 15:05:27 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:14:41 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ -#include "push_swap.h" +#include "utils.h" void clear_stack(t_stack **p_stack, void (*del)(void *)) { diff --git a/src/utils/get_content.c b/src/utils/get_content.c index aadad03..bc795e5 100644 --- a/src/utils/get_content.c +++ b/src/utils/get_content.c @@ -6,11 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/08 07:43:54 by reasuke #+# #+# */ -/* Updated: 2024/02/08 07:44:10 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:14:37 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ -#include "push_swap.h" +#include "utils.h" t_content *get_content(t_stack *st) { diff --git a/src/utils/get_first_index.c b/src/utils/get_first_index.c index 1560b5d..8e5ac8d 100644 --- a/src/utils/get_first_index.c +++ b/src/utils/get_first_index.c @@ -6,11 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/17 18:27:37 by reasuke #+# #+# */ -/* Updated: 2024/02/10 20:56:13 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:14:47 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ -#include "push_swap.h" +#include "utils.h" int get_first_index(t_stack **p_stack) { diff --git a/src/utils/get_second_index.c b/src/utils/get_second_index.c index 8160265..2575a90 100644 --- a/src/utils/get_second_index.c +++ b/src/utils/get_second_index.c @@ -6,11 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/17 18:28:02 by reasuke #+# #+# */ -/* Updated: 2024/02/10 20:56:06 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:14:50 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ -#include "push_swap.h" +#include "utils.h" int get_second_index(t_stack **p_stack) { diff --git a/src/utils/get_third_index.c b/src/utils/get_third_index.c index 43faabe..ff09362 100644 --- a/src/utils/get_third_index.c +++ b/src/utils/get_third_index.c @@ -6,11 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/17 18:28:02 by reasuke #+# #+# */ -/* Updated: 2024/02/10 20:57:07 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:14:52 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ -#include "push_swap.h" +#include "utils.h" int get_third_index(t_stack **p_stack) { diff --git a/src/utils/stack_size.c b/src/utils/stack_size.c index 3b7d760..7adfe82 100644 --- a/src/utils/stack_size.c +++ b/src/utils/stack_size.c @@ -6,11 +6,11 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/23 16:25:21 by reasuke #+# #+# */ -/* Updated: 2024/02/07 15:05:54 by reasuke ### ########.fr */ +/* Updated: 2024/02/20 14:14:56 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ -#include "push_swap.h" +#include "utils.h" int stack_size(t_stack *stack) { 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