Skip to content

Conversation

nik-rev
Copy link

@nik-rev nik-rev commented Oct 20, 2025

No description provided.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 18668224799

Details

  • 7 of 7 (100.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 64.846%

Totals Coverage Status
Change from base Build 18169995909: 0.0%
Covered Lines: 950
Relevant Lines: 1465

💛 - Coveralls

@epage
Copy link
Contributor

epage commented Oct 21, 2025

How much of a difference does this make in practice?

@nik-rev
Copy link
Author

nik-rev commented Oct 21, 2025

For 1 million TOML keys, it took 8.82 seconds and now it takes 8.25 seconds to call Config::build(). 6.5% increase.

Feel free to close the PR if you think it's not worth it. I needed to understand a region of code in this crate and found a possible, albeit minor, improvement

benchmark

#[test]
#[cfg(feature = "toml")]
fn benchmark() {
    use std::time::Instant;
    use config::{Config, File, FileFormat};

    let config = (0..1_000_000)
        .map(|i| format!("key{i} = {i}\n"))
        .collect::<String>();

    let c = Config::builder().add_source(File::from_str(&config, FileFormat::Toml));
    let before = Instant::now();
    let c = c.build();
    println!("{:?}", before.elapsed());
}

Outputs (with this PR):

8.200018192s
8.270070666s
8.27713242s

Before this PR:

8.779736576s
8.760608855s
8.913664742s

@epage
Copy link
Contributor

epage commented Oct 21, 2025

I think I'll hold off. If we want to improve this, likely the best way is to deserialize directly to our own type

@epage epage closed this Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants