Skip to content

Commit

Permalink
Put benchmarking behind a feature wall
Browse files Browse the repository at this point in the history
  • Loading branch information
datawater committed Jun 28, 2024
1 parent 9c0f7a8 commit bbd6e37
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pgn-lexer = { git = "https://github.com/datawater/pgn-lexer" }

[features]
safe_u24 = []
benchmark = []

[profile.release]
opt-level = 3
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// TODO: Define and Write documentation for the CMBR Standard.
// TODO: Seperate the cli and libcmbr
#![feature(test)]
#![allow(non_upper_case_globals)]

mod cmbr;
Expand Down
5 changes: 5 additions & 0 deletions tests/pgn/ast.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(feature = "benchmark")]
#[feature(test)]
extern crate test;

#[cfg(test)]
Expand All @@ -6,7 +8,9 @@ mod pgn_tests {
use project_root::get_project_root;
use std::fs::File;

#[cfg(feature = "benchmark")]
use super::test::Bencher;

use crate::pgn;

#[test]
Expand Down Expand Up @@ -40,6 +44,7 @@ mod pgn_tests {
assert_eq!(format!("{:?}", ast), ast_expected);
}

#[cfg(feature = "benchmark")]
#[bench]
fn bench_ast(b: &mut Bencher) {
let file_path = get_project_root().unwrap().join("data/twic1544.pgn");
Expand Down
5 changes: 5 additions & 0 deletions tests/pgn/lex.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(feature = "benchmark")]
#[feature(test)]
extern crate test;

#[cfg(test)]
Expand All @@ -7,7 +9,9 @@ mod pgn_tests {
use project_root::get_project_root;
use std::{collections::VecDeque, fs::File};

#[cfg(feature = "benchmark")]
use super::test::Bencher;

use crate::pgn;

#[test]
Expand Down Expand Up @@ -108,6 +112,7 @@ mod pgn_tests {
assert_eq!(tokens_expected, tokens);
}

#[cfg(feature = "benchmark")]
#[bench]
fn bench_lex(b: &mut Bencher) {
let file_path = get_project_root().unwrap().join("data/twic1544.pgn");
Expand Down

0 comments on commit bbd6e37

Please sign in to comment.