forked from gobanos/cargo-aoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request gobanos#17 from gobanos/try_run
0.2.0
- Loading branch information
Showing
13 changed files
with
226 additions
and
84 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
[package] | ||
name = "aoc-autobench" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
authors = ["Grégory Obanos <gregory.obanos@gmail.com>"] | ||
|
||
[dependencies] | ||
{CRATE_NAME} = { path = "../../.." } | ||
aoc-runner = "0.1.0" | ||
aoc-runner = "0.2.0" | ||
|
||
[dev-dependencies] | ||
criterion = "0.2.5" | ||
|
||
{PROFILE} | ||
|
||
[[bench]] | ||
name = "aoc_benchmark" | ||
harness = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
[package] | ||
name = "aoc-autobuild" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
authors = ["Grégory Obanos <gregory.obanos@gmail.com>"] | ||
|
||
[dependencies] | ||
{CRATE_NAME} = { path = "../../.." } | ||
aoc-runner = "0.1.0" | ||
aoc-runner = "0.2.0" | ||
|
||
{PROFILE} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
let mut {GEN_NAME} = Vec::new(); | ||
|
||
{IMPLS} | ||
|
||
c.bench_functions("Generator Day{DAY}", {GEN_NAME}, ()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
{ | ||
let input = input_day{DAY}.clone(); | ||
let fun = Fun::new("{NAME}", move |b, _| b.iter(|| Factory::{RUNNER_NAME}(input.clone()).unwrap())); | ||
{GEN_NAME}.push(fun); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
|
||
{ | ||
let runner = Factory::{RUNNER_NAME}(ArcStr::from(include_str!("../../../../input/{INPUT}"))); | ||
let fun = Fun::new("{NAME}", move |b, _| b.iter(|| runner.run())); | ||
let runner = Factory::{RUNNER_NAME}(input_day{DAY}.clone()) | ||
.expect("failed to generate input for {NAME}"); | ||
let fun = Fun::new("{NAME}", move |b, _| b.iter(|| runner.bench(black_box))); | ||
{PART_NAME}.push(fun); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
let input_day{DAY} = ArcStr::from(include_str!("../../../../input/{YEAR}/day{DAY}.txt")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
{ | ||
use std::time::Instant; | ||
use aoc_runner::ArcStr; | ||
|
||
let start_time = Instant::now(); | ||
let runner = Factory::{RUNNER_NAME}(ArcStr::from(include_str!("../../../../input/{INPUT}"))); | ||
let inter_time = Instant::now(); | ||
let result = runner.run(); | ||
let final_time = Instant::now(); | ||
println!("{RUNNER_DISPLAY} : {}\n\tgenerator: {:?},\n\trunner: {:?}\n", result, (inter_time - start_time), (final_time - inter_time)); | ||
} | ||
{ | ||
let start_time = Instant::now(); | ||
match Factory::{RUNNER_NAME}(input_day{DAY}.clone()) { | ||
Ok(runner) => { | ||
let inter_time = Instant::now(); | ||
match runner.try_run() { | ||
Ok(result) => { | ||
let final_time = Instant::now(); | ||
println!("{RUNNER_DISPLAY} : {}\n\tgenerator: {:?},\n\trunner: {:?}\n", result, (inter_time - start_time), (final_time - inter_time)); | ||
}, | ||
Err(e) => eprintln!("{RUNNER_DISPLAY} : FAILED while running :\n{:#?}\n", e) | ||
} | ||
}, | ||
Err(e) => eprintln!("{RUNNER_DISPLAY} : FAILED while generating :\n{:#?}\n", e) | ||
} | ||
} |