Skip to content

Commit 45b4353

Browse files
committed
Add benchmark for log crate proxy
1 parent 5a22c32 commit 45b4353

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,12 @@ jobs:
224224
- name: Restore cargo caches
225225
uses: Swatinem/rust-cache@v2
226226
- name: Run benchmark
227-
run: cargo +nightly bench --features "multi-thread,runtime-pattern,serde_json" --bench spdlog_rs --bench spdlog_rs_pattern | tee bench-results.txt
227+
run: |
228+
cargo +nightly bench --features "multi-thread,runtime-pattern,serde_json,log" \
229+
--bench spdlog_rs \
230+
--bench spdlog_rs_pattern \
231+
--bench spdlog_rs_log_crate_proxy \
232+
| tee bench-results.txt
228233
- name: Discard irrelevant changes
229234
run: git checkout -- spdlog/Cargo.toml
230235
- name: Process results

spdlog/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ name = "spdlog_rs_pattern"
111111
path = "benches/spdlog-rs/pattern.rs"
112112
required-features = ["runtime-pattern", "serde_json"]
113113
[[bench]]
114+
name = "spdlog_rs_log_crate_proxy"
115+
path = "benches/spdlog-rs/log_crate_proxy.rs"
116+
required-features = ["log"]
117+
[[bench]]
114118
name = "fast_log"
115119
path = "benches/fast_log/main.rs"
116120
harness = false
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#![feature(test)]
2+
3+
extern crate test;
4+
5+
#[path = "../common/mod.rs"]
6+
mod common;
7+
8+
use std::sync::Arc;
9+
10+
use test::Bencher;
11+
12+
include!(concat!(
13+
env!("OUT_DIR"),
14+
"/test_utils/common_for_integration_test.rs"
15+
));
16+
use test_utils::*;
17+
18+
fn init() {
19+
if spdlog::init_log_crate_proxy().is_ok() {
20+
spdlog::set_default_logger(Arc::new(build_test_logger(|b| {
21+
b.error_handler(|err| panic!("an error occurred: {err}"))
22+
})));
23+
}
24+
log::set_max_level(log::LevelFilter::max());
25+
}
26+
27+
#[bench]
28+
fn bench_log_crate_proxy(bencher: &mut Bencher) {
29+
init();
30+
bencher.iter(|| log::info!(bench_log_message!()))
31+
}

0 commit comments

Comments
 (0)