Skip to content

Commit

Permalink
Chore: Rework public/private of methods
Browse files Browse the repository at this point in the history
  • Loading branch information
joshleaves committed Mar 21, 2024
1 parent 9d1d441 commit e136c72
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 70 deletions.
50 changes: 25 additions & 25 deletions benches/year_2015.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use advent_rs::year_2015::day_24;
use advent_rs::year_2015::day_25;
use criterion::{black_box, criterion_group, criterion_main, Criterion};

pub fn year_2015_day_01(c: &mut Criterion) {
fn year_2015_day_01(c: &mut Criterion) {
let mut g2015_day_01 = c.benchmark_group("year_2015::day_01");
let input_year_2015_day_01 = include_str!("../inputs/year_2015/day_01_input");
g2015_day_01.bench_function("year_2015::day_01_v1", |b| {
Expand All @@ -37,7 +37,7 @@ pub fn year_2015_day_01(c: &mut Criterion) {
g2015_day_01.finish();
}

pub fn year_2015_day_02(c: &mut Criterion) {
fn year_2015_day_02(c: &mut Criterion) {
let mut g2015_day_02 = c.benchmark_group("year_2015::day_02");
let input_year_2015_day_02 = include_str!("../inputs/year_2015/day_02_input");
g2015_day_02.bench_function("year_2015::day_02_v1", |b| {
Expand All @@ -49,7 +49,7 @@ pub fn year_2015_day_02(c: &mut Criterion) {
g2015_day_02.finish();
}

pub fn year_2015_day_03(c: &mut Criterion) {
fn year_2015_day_03(c: &mut Criterion) {
let mut g2015_day_03 = c.benchmark_group("year_2015::day_03");
g2015_day_03.sample_size(60);
let input_year_2015_day_03 = include_str!("../inputs/year_2015/day_03_input");
Expand All @@ -62,7 +62,7 @@ pub fn year_2015_day_03(c: &mut Criterion) {
g2015_day_03.finish();
}

pub fn year_2015_day_04(c: &mut Criterion) {
fn year_2015_day_04(c: &mut Criterion) {
let mut g2015_day_04 = c.benchmark_group("year_2015::day_04");
g2015_day_04.sample_size(10);
let input_year_2015_day_04 = include_str!("../inputs/year_2015/day_04_input");
Expand All @@ -75,7 +75,7 @@ pub fn year_2015_day_04(c: &mut Criterion) {
g2015_day_04.finish();
}

pub fn year_2015_day_05(c: &mut Criterion) {
fn year_2015_day_05(c: &mut Criterion) {
let mut g2015_day_05 = c.benchmark_group("year_2015::day_05");
let input_year_2015_day_05 = include_str!("../inputs/year_2015/day_05_input");
g2015_day_05.bench_function("year_2015::day_05_v1", |b| {
Expand All @@ -87,7 +87,7 @@ pub fn year_2015_day_05(c: &mut Criterion) {
g2015_day_05.finish();
}

pub fn year_2015_day_06(c: &mut Criterion) {
fn year_2015_day_06(c: &mut Criterion) {
let mut g2015_day_06 = c.benchmark_group("year_2015::day_06");
let input_year_2015_day_06 = include_str!("../inputs/year_2015/day_06_input");
g2015_day_06.bench_function("year_2015::day_06_v1", |b| {
Expand All @@ -99,7 +99,7 @@ pub fn year_2015_day_06(c: &mut Criterion) {
g2015_day_06.finish();
}

pub fn year_2015_day_07(c: &mut Criterion) {
fn year_2015_day_07(c: &mut Criterion) {
let mut g2015_day_07 = c.benchmark_group("year_2015::day_07");
let input_year_2015_day_07 = include_str!("../inputs/year_2015/day_07_input");
g2015_day_07.bench_function("year_2015::day_07_v1", |b| {
Expand All @@ -111,7 +111,7 @@ pub fn year_2015_day_07(c: &mut Criterion) {
g2015_day_07.finish();
}

pub fn year_2015_day_08(c: &mut Criterion) {
fn year_2015_day_08(c: &mut Criterion) {
let mut g2015_day_08 = c.benchmark_group("year_2015::day_08");
let input_year_2015_day_08 = include_str!("../inputs/year_2015/day_08_input");
g2015_day_08.bench_function("year_2015::day_08_v1", |b| {
Expand All @@ -123,7 +123,7 @@ pub fn year_2015_day_08(c: &mut Criterion) {
g2015_day_08.finish();
}

pub fn year_2015_day_09(c: &mut Criterion) {
fn year_2015_day_09(c: &mut Criterion) {
let mut g2015_day_09 = c.benchmark_group("year_2015::day_09");
let input_year_2015_day_09 = include_str!("../inputs/year_2015/day_09_input");
g2015_day_09.bench_function("year_2015::day_09_v1", |b| {
Expand All @@ -135,7 +135,7 @@ pub fn year_2015_day_09(c: &mut Criterion) {
g2015_day_09.finish();
}

pub fn year_2015_day_10(c: &mut Criterion) {
fn year_2015_day_10(c: &mut Criterion) {
let mut g2015_day_10 = c.benchmark_group("year_2015::day_10");
let input_year_2015_day_10 = include_str!("../inputs/year_2015/day_10_input");
g2015_day_10.bench_function("year_2015::day_10_v1", |b| {
Expand All @@ -147,7 +147,7 @@ pub fn year_2015_day_10(c: &mut Criterion) {
g2015_day_10.finish();
}

pub fn year_2015_day_11(c: &mut Criterion) {
fn year_2015_day_11(c: &mut Criterion) {
let mut g2015_day_11 = c.benchmark_group("year_2015::day_11");
let input_year_2015_day_11 = include_str!("../inputs/year_2015/day_11_input");
g2015_day_11.bench_function("year_2015::day_11_v1", |b| {
Expand All @@ -159,7 +159,7 @@ pub fn year_2015_day_11(c: &mut Criterion) {
g2015_day_11.finish();
}

pub fn year_2015_day_12(c: &mut Criterion) {
fn year_2015_day_12(c: &mut Criterion) {
let mut g2015_day_12 = c.benchmark_group("year_2015::day_12");
let input_year_2015_day_12 = include_str!("../inputs/year_2015/day_12_input");
g2015_day_12.bench_function("year_2015::day_12_v1", |b| {
Expand All @@ -171,7 +171,7 @@ pub fn year_2015_day_12(c: &mut Criterion) {
g2015_day_12.finish();
}

pub fn year_2015_day_13(c: &mut Criterion) {
fn year_2015_day_13(c: &mut Criterion) {
let mut g2015_day_13 = c.benchmark_group("year_2015::day_13");
let input_year_2015_day_13 = include_str!("../inputs/year_2015/day_13_input");
g2015_day_13.bench_function("year_2015::day_13_v1", |b| {
Expand All @@ -183,7 +183,7 @@ pub fn year_2015_day_13(c: &mut Criterion) {
g2015_day_13.finish();
}

pub fn year_2015_day_14(c: &mut Criterion) {
fn year_2015_day_14(c: &mut Criterion) {
let mut g2015_day_14 = c.benchmark_group("year_2015::day_14");
let input_year_2015_day_14 = include_str!("../inputs/year_2015/day_14_input");
g2015_day_14.bench_function("year_2015::day_14_v1", |b| {
Expand All @@ -195,7 +195,7 @@ pub fn year_2015_day_14(c: &mut Criterion) {
g2015_day_14.finish();
}

pub fn year_2015_day_15(c: &mut Criterion) {
fn year_2015_day_15(c: &mut Criterion) {
let mut g2015_day_15 = c.benchmark_group("year_2015::day_15");
let input_year_2015_day_15 = include_str!("../inputs/year_2015/day_15_input");
g2015_day_15.bench_function("year_2015::day_15_v1", |b| {
Expand All @@ -207,7 +207,7 @@ pub fn year_2015_day_15(c: &mut Criterion) {
g2015_day_15.finish();
}

pub fn year_2015_day_16(c: &mut Criterion) {
fn year_2015_day_16(c: &mut Criterion) {
let mut g2015_day_16 = c.benchmark_group("year_2015::day_16");
let input_year_2015_day_16 = include_str!("../inputs/year_2015/day_16_input");
g2015_day_16.bench_function("year_2015::day_16_v1", |b| {
Expand All @@ -219,7 +219,7 @@ pub fn year_2015_day_16(c: &mut Criterion) {
g2015_day_16.finish();
}

pub fn year_2015_day_17(c: &mut Criterion) {
fn year_2015_day_17(c: &mut Criterion) {
let mut g2015_day_17 = c.benchmark_group("year_2015::day_17");
let input_year_2015_day_17 = include_str!("../inputs/year_2015/day_17_input");
g2015_day_17.bench_function("year_2015::day_17_v1", |b| {
Expand All @@ -231,7 +231,7 @@ pub fn year_2015_day_17(c: &mut Criterion) {
g2015_day_17.finish();
}

pub fn year_2015_day_18(c: &mut Criterion) {
fn year_2015_day_18(c: &mut Criterion) {
let mut g2015_day_18 = c.benchmark_group("year_2015::day_18");
let input_year_2015_day_18 = include_str!("../inputs/year_2015/day_18_input");
g2015_day_18.bench_function("year_2015::day_18_v1", |b| {
Expand All @@ -243,7 +243,7 @@ pub fn year_2015_day_18(c: &mut Criterion) {
g2015_day_18.finish();
}

pub fn year_2015_day_19(c: &mut Criterion) {
fn year_2015_day_19(c: &mut Criterion) {
let mut g2015_day_19 = c.benchmark_group("year_2015::day_19");
let input_year_2015_day_19 = include_str!("../inputs/year_2015/day_19_input");
g2015_day_19.bench_function("year_2015::day_19_v1", |b| {
Expand All @@ -255,7 +255,7 @@ pub fn year_2015_day_19(c: &mut Criterion) {
g2015_day_19.finish();
}

pub fn year_2015_day_20(c: &mut Criterion) {
fn year_2015_day_20(c: &mut Criterion) {
let mut g2015_day_20 = c.benchmark_group("year_2015::day_20");
let input_year_2015_day_20 = include_str!("../inputs/year_2015/day_20_input");
g2015_day_20.bench_function("year_2015::day_20_v1", |b| {
Expand All @@ -267,7 +267,7 @@ pub fn year_2015_day_20(c: &mut Criterion) {
g2015_day_20.finish();
}

pub fn year_2015_day_21(c: &mut Criterion) {
fn year_2015_day_21(c: &mut Criterion) {
let mut g2015_day_21 = c.benchmark_group("year_2015::day_21");
let input_year_2015_day_21 = include_str!("../inputs/year_2015/day_21_input");
g2015_day_21.bench_function("year_2015::day_21_v1", |b| {
Expand All @@ -279,7 +279,7 @@ pub fn year_2015_day_21(c: &mut Criterion) {
g2015_day_21.finish();
}

pub fn year_2015_day_22(c: &mut Criterion) {
fn year_2015_day_22(c: &mut Criterion) {
let mut g2015_day_22 = c.benchmark_group("year_2015::day_22");
let input_year_2015_day_22 = include_str!("../inputs/year_2015/day_22_input");
g2015_day_22.bench_function("year_2015::day_22_v1", |b| {
Expand All @@ -291,7 +291,7 @@ pub fn year_2015_day_22(c: &mut Criterion) {
g2015_day_22.finish();
}

pub fn year_2015_day_23(c: &mut Criterion) {
fn year_2015_day_23(c: &mut Criterion) {
let mut g2015_day_23 = c.benchmark_group("year_2015::day_23");
let input_year_2015_day_23 = include_str!("../inputs/year_2015/day_23_input");
g2015_day_23.bench_function("year_2015::day_23_v1", |b| {
Expand All @@ -303,7 +303,7 @@ pub fn year_2015_day_23(c: &mut Criterion) {
g2015_day_23.finish();
}

pub fn year_2015_day_24(c: &mut Criterion) {
fn year_2015_day_24(c: &mut Criterion) {
let mut g2015_day_24 = c.benchmark_group("year_2015::day_24");
let input_year_2015_day_24 = include_str!("../inputs/year_2015/day_24_input");
g2015_day_24.bench_function("year_2015::day_24_v1", |b| {
Expand All @@ -315,7 +315,7 @@ pub fn year_2015_day_24(c: &mut Criterion) {
g2015_day_24.finish();
}

pub fn year_2015_day_25(c: &mut Criterion) {
fn year_2015_day_25(c: &mut Criterion) {
let mut g2015_day_25 = c.benchmark_group("year_2015::day_25");
let input_year_2015_day_25 = include_str!("../inputs/year_2015/day_25_input");
g2015_day_25.bench_function("year_2015::day_25", |b| {
Expand Down
8 changes: 4 additions & 4 deletions benches/year_2015_day_01.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn day_01_v1_naive(input: &str) -> i16 {
right - left
}

pub fn day_01_v1_fast(input: impl Into<String>) -> i16 {
fn day_01_v1_fast(input: impl Into<String>) -> i16 {
let mut level: i16 = 0;
let nums: Vec<u16> = unsafe { mem::transmute::<String, Vec<u16>>(input.into()) };
for num in nums {
Expand All @@ -35,7 +35,7 @@ pub fn day_01_v1_fast(input: impl Into<String>) -> i16 {
level
}

pub fn day_01_v2_fast(input: impl Into<String>) -> i16 {
fn day_01_v2_fast(input: impl Into<String>) -> i16 {
let mut level: i16 = 0;
let nums: Vec<u16> = unsafe { mem::transmute::<String, Vec<u16>>(input.into()) };
for (index, num) in nums.iter().enumerate() {
Expand Down Expand Up @@ -75,7 +75,7 @@ pub fn day_01_v2_fast(input: impl Into<String>) -> i16 {
0
}

pub fn bench_year_2015_day_01_v1(c: &mut Criterion) {
fn bench_year_2015_day_01_v1(c: &mut Criterion) {
let mut group = c.benchmark_group("year_2015::day_01_v1");
group.warm_up_time(Duration::from_millis(100));
let input = include_str!("../inputs/year_2015/day_01_input");
Expand All @@ -93,7 +93,7 @@ pub fn bench_year_2015_day_01_v1(c: &mut Criterion) {
group.finish();
}

pub fn bench_year_2015_day_01_v2(c: &mut Criterion) {
fn bench_year_2015_day_01_v2(c: &mut Criterion) {
let mut group = c.benchmark_group("year_2015::day_01_v2");
group.warm_up_time(Duration::from_millis(100));
let input = include_str!("../inputs/year_2015/day_01_input");
Expand Down
6 changes: 3 additions & 3 deletions benches/year_2015_day_03.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn move_character(pos: (i8, i8), direction: char) -> (i8, i8) {
newpos
}

pub fn day_03_v1_bset(input: &str) -> usize {
fn day_03_v1_bset(input: &str) -> usize {
let mut santa: (i8, i8) = (0, 0);
let mut houses = BTreeSet::from([santa]);

Expand All @@ -27,7 +27,7 @@ pub fn day_03_v1_bset(input: &str) -> usize {
return houses.len() as usize;
}

pub fn day_03_v2_bset(input: &str) -> usize {
fn day_03_v2_bset(input: &str) -> usize {
let mut santa: (i8, i8) = (0, 0);
let mut robot: (i8, i8) = (0, 0);
let mut houses = BTreeSet::from([santa]);
Expand All @@ -42,7 +42,7 @@ pub fn day_03_v2_bset(input: &str) -> usize {
return houses.len() as usize;
}

pub fn bench_year_2015_day_03_sets(c: &mut Criterion) {
fn bench_year_2015_day_03_sets(c: &mut Criterion) {
let input = include_str!("../inputs/year_2015/day_03_input");
let mut group_v1 = c.benchmark_group("year_2015::day_03_v1");
group_v1.warm_up_time(Duration::from_millis(100));
Expand Down
4 changes: 2 additions & 2 deletions benches/year_2015_day_05.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ fn string_is_nice_v1_contains(input: &str) -> bool {
return repeated && vowels >= 3;
}

pub fn day_05_v1_contains(input: &str) -> u32 {
fn day_05_v1_contains(input: &str) -> u32 {
return input
.lines()
.filter(|line| string_is_nice_v1_contains(line))
.count() as u32;
}

pub fn bench_year_2015_day_05_v1(c: &mut Criterion) {
fn bench_year_2015_day_05_v1(c: &mut Criterion) {
let input = include_str!("../inputs/year_2015/day_05_input");
let mut group = c.benchmark_group("year_2015::day_05_v1");
group.warm_up_time(Duration::from_millis(100));
Expand Down
Loading

0 comments on commit e136c72

Please sign in to comment.