Skip to content

Commit 002aa3b

Browse files
perf: add basic compile benchmarks (#21)
1 parent 5d985b8 commit 002aa3b

8 files changed

Lines changed: 443 additions & 1 deletion

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,6 @@ target/
161161

162162
# mdBook
163163
book/book/
164+
165+
# Benchmarks
166+
benchmarks/compile/results.md

Cargo.lock

Lines changed: 113 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["examples/*", "packages/*"]
2+
members = ["benchmarks/*", "examples/*", "packages/*"]
33
resolver = "2"
44

55
[workspace.package]

benchmarks/compile/Cargo.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[package]
2+
name = "fortifier-benchmark-compile"
3+
description = "Fortifier compile time benchmark."
4+
5+
authors.workspace = true
6+
edition.workspace = true
7+
license.workspace = true
8+
repository.workspace = true
9+
version.workspace = true
10+
11+
[features]
12+
default = []
13+
fortifier = ["dep:fortifier"]
14+
structs-1-fields-10 = []
15+
structs-10-fields-10 = []
16+
validator = ["dep:validator"]
17+
18+
[dependencies]
19+
fortifier = { workspace = true, features = [
20+
"email",
21+
"serde",
22+
"url",
23+
], optional = true }
24+
validator = { version = "0.20.0", features = ["derive"], optional = true }
25+
26+
[lints]
27+
workspace = true

benchmarks/compile/run.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
set -euxo pipefail
4+
5+
suites=(
6+
structs-1-fields-10
7+
structs-10-fields-10
8+
)
9+
10+
crates=(
11+
fortifier
12+
validator
13+
)
14+
15+
hyperfine \
16+
--setup 'cargo build -p fortifier-benchmark-compile --features={suite},{crate}' \
17+
--prepare 'cargo clean -p fortifier-benchmark-compile' \
18+
--shell=none \
19+
--export-markdown results.md \
20+
--parameter-list suite "$(IFS=, ; echo "${suites[*]}")" \
21+
--parameter-list crate "$(IFS=, ; echo "${crates[*]}")" \
22+
--command-name '{suite} {crate}' \
23+
'cargo build -p fortifier-benchmark-compile --features={suite},{crate}'

benchmarks/compile/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#[cfg(feature = "structs-10-fields-10")]
2+
pub mod structs_10_fields_10;
3+
#[cfg(feature = "structs-1-fields-10")]
4+
pub mod structs_1_fields_10;

0 commit comments

Comments
 (0)