perf: pre-allocate arrays and maps#709
Closed
nik-rev wants to merge 1 commit into
Closed
Conversation
Pull Request Test Coverage Report for Build 18668224799Details
💛 - Coveralls |
Contributor
|
How much of a difference does this make in practice? |
Author
|
For 1 million TOML keys, it took 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): Before this PR: |
Contributor
|
I think I'll hold off. If we want to improve this, likely the best way is to deserialize directly to our own type |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.