Skip to content

Commit 80d36e7

Browse files
committed
Add ftlog benchmark for comparison
1 parent 21d01f3 commit 80d36e7

File tree

5 files changed

+98
-4
lines changed

5 files changed

+98
-4
lines changed

spdlog/Cargo.toml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ sloggers = "=2.2.0"
7878
log4rs = "=1.3.0"
7979
fern = "=0.6.2"
8080
flexi_logger = "=0.28.3"
81+
ftlog = "=0.2.14"
8182
tracing = "=0.1.40"
8283
tracing-subscriber = "=0.3.18"
8384
tracing-appender = "=0.2.3"
@@ -93,25 +94,34 @@ required-features = ["multi-thread"]
9394
[[bench]]
9495
name = "spdlog_rs"
9596
path = "benches/spdlog-rs/spdlog_rs.rs"
96-
9797
[[bench]]
9898
name = "spdlog_rs_compare_with_cpp_spdlog"
9999
path = "benches/spdlog-rs/compare_with_cpp_spdlog.rs"
100100
harness = false
101-
102101
[[bench]]
103102
name = "spdlog_rs_compare_with_cpp_spdlog_async"
104103
path = "benches/spdlog-rs/compare_with_cpp_spdlog_async.rs"
105104
harness = false
106-
107105
[[bench]]
108106
name = "spdlog_rs_pattern"
109107
path = "benches/spdlog-rs/pattern.rs"
108+
[[bench]]
109+
name = "ftlog"
110+
path = "benches/ftlog/main.rs"
111+
harness = false
112+
[[bench]]
113+
name = "ftlog_1_file_async"
114+
path = "benches/ftlog/1_file_async.rs"
115+
[[bench]]
116+
name = "ftlog_2_rotating_daily"
117+
path = "benches/ftlog/2_rotating_daily.rs"
118+
[[bench]]
119+
name = "ftlog_3_level_off"
120+
path = "benches/ftlog/3_level_off.rs"
110121

111122
[[example]]
112123
name = "06_compatible_with_log_crate"
113124
required-features = ["log"]
114-
115125
[[example]]
116126
name = "07_async_pool_sink"
117127
required-features = ["multi-thread"]

spdlog/benches/ftlog/1_file_async.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#![feature(test)]
2+
3+
extern crate test;
4+
5+
#[path = "../common/mod.rs"]
6+
mod common;
7+
8+
use ftlog::appender::FileAppender;
9+
use log::info;
10+
use test::Bencher;
11+
12+
unavailable_bench!(bench_1_file);
13+
14+
#[bench]
15+
fn bench_2_file_async(bencher: &mut Bencher) {
16+
let path = common::BENCH_LOGS_PATH.join("file_async.log");
17+
18+
let _guard = ftlog::builder()
19+
.root(FileAppender::builder().path(path).build())
20+
.try_init()
21+
.unwrap();
22+
23+
bencher.iter(|| info!(bench_log_message!()))
24+
}
25+
26+
unavailable_bench!(bench_3_rotating_file_size);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#![feature(test)]
2+
3+
extern crate test;
4+
5+
#[path = "../common/mod.rs"]
6+
mod common;
7+
8+
use ftlog::appender::{FileAppender, Period};
9+
use log::info;
10+
use test::Bencher;
11+
12+
#[bench]
13+
fn bench_4_rotating_daily(bencher: &mut Bencher) {
14+
let path = common::BENCH_LOGS_PATH.join("rotating_daily.log");
15+
16+
let _guard = ftlog::builder()
17+
.root(
18+
FileAppender::builder()
19+
.path(path)
20+
.rotate(Period::Day)
21+
.build(),
22+
)
23+
.try_init()
24+
.unwrap();
25+
26+
bencher.iter(|| info!(bench_log_message!()))
27+
}

spdlog/benches/ftlog/3_level_off.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#![feature(test)]
2+
3+
extern crate test;
4+
5+
#[path = "../common/mod.rs"]
6+
mod common;
7+
8+
use ftlog::{appender::FileAppender, LevelFilter};
9+
use log::info;
10+
use test::Bencher;
11+
12+
#[bench]
13+
fn bench_5_level_off(bencher: &mut Bencher) {
14+
let path = common::BENCH_LOGS_PATH.join("level_off.log");
15+
16+
let _guard = ftlog::builder()
17+
.root(FileAppender::builder().path(path).build())
18+
.max_log_level(LevelFilter::Off)
19+
.try_init()
20+
.unwrap();
21+
22+
bencher.iter(|| info!(bench_log_message!()))
23+
}

spdlog/benches/ftlog/main.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(test)]
2+
3+
extern crate test;
4+
5+
#[path = "../common/mod.rs"]
6+
mod common;
7+
8+
aggregate_bench_main!();

0 commit comments

Comments
 (0)