Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create export file before first benchmark #340

Merged
merged 3 commits into from
Oct 18, 2020

Conversation

s1ck
Copy link
Contributor

@s1ck s1ck commented Oct 17, 2020

#306

A second request in #306 was to check if the file specified by the --export-* options is accessible. In this PR, we create the file when the ExportManager is initialized and just open it in write mode when writing the results.

@@ -55,7 +55,9 @@ impl ExportManager {
}

/// Add an additional exporter to the ExportManager
pub fn add_exporter(&mut self, export_type: ExportType, filename: &str) {
pub fn add_exporter(&mut self, export_type: ExportType, filename: &str) -> Result<()> {
let _ = File::create(filename)?;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another idea could be to open the file here (in write-mode, as below) and store the file handle with the exporter - instead of (or in addition to) the filename.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. If we add file: File to the struct, we however need to use the ExportManager as &mut everywhere since we need a &mut self in write_results. It works, but requires more changes. Did you think of a different way?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave it as it is for now - thank you!

@sharkdp
Copy link
Owner

sharkdp commented Oct 17, 2020

Thank you, this looks great. I have one comment, but I'm also okay with leaving it as it is, if you prefer.

Could you please also adapt the CHANGELOG (see your other PR)?

@sharkdp sharkdp merged commit 990ed45 into sharkdp:master Oct 18, 2020
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.

2 participants