-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
285 additions
and
171 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use criterion::{Criterion, criterion_group, criterion_main}; | ||
use brumby::entity::{MarketType, OutcomeType, Player, Side}; | ||
|
||
use brumby::interval::{Exploration, explore, IntervalConfig, isolate}; | ||
|
||
fn criterion_benchmark(c: &mut Criterion) { | ||
let player = Player::Named(Side::Home, "Markos".into()); | ||
fn prepare(intervals: u8, max_total_goals: u16, player: Player) -> Exploration { | ||
explore(&IntervalConfig { | ||
intervals, | ||
home_prob: 0.25, | ||
away_prob: 0.25, | ||
common_prob: 0.25, | ||
max_total_goals, | ||
players: vec![(player, 0.25)], | ||
}) | ||
} | ||
|
||
// sanity check | ||
let exploration = prepare(18, u16::MAX,player.clone()); | ||
// println!("prospects: {}", exploration.prospects.len()); | ||
let isolated = isolate(&MarketType::AnytimeGoalscorer, &OutcomeType::Player(player.clone()), &exploration.prospects, &exploration.player_lookup); | ||
assert!(isolated > 0.0); | ||
|
||
c.bench_function("cri_isolate_first_goalscorer_18_unbounded", |b| { | ||
let exploration = prepare(18, u16::MAX, player.clone()); | ||
b.iter(|| { | ||
isolate(&MarketType::AnytimeGoalscorer, &OutcomeType::Player(player.clone()), &exploration.prospects, &exploration.player_lookup) | ||
}); | ||
}); | ||
|
||
c.bench_function("cri_isolate_first_goalscorer_90_max_8", |b| { | ||
let exploration = prepare(90, 8, player.clone()); | ||
b.iter(|| { | ||
isolate(&MarketType::AnytimeGoalscorer, &OutcomeType::Player(player.clone()), &exploration.prospects, &exploration.player_lookup) | ||
}); | ||
}); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
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
Oops, something went wrong.