Skip to content

Commit a07e0a1

Browse files
committed
Use a BufWriter for dumping profile output
1 parent 04dfc06 commit a07e0a1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ fn get_paths(env_variable_name: &str) -> Vec<String> {
279279

280280
#[cfg(feature = "flame-it")]
281281
fn write_profile(matches: &ArgMatches) -> Result<(), Box<dyn std::error::Error>> {
282-
use std::fs::File;
282+
use std::{fs, io};
283283

284284
enum ProfileFormat {
285285
Html,
@@ -306,12 +306,14 @@ fn write_profile(matches: &ArgMatches) -> Result<(), Box<dyn std::error::Error>>
306306
ProfileFormat::Speedscope => "flamescope.json".as_ref(),
307307
});
308308

309-
let profile_output: Box<dyn std::io::Write> = if profile_output == "-" {
310-
Box::new(std::io::stdout())
309+
let profile_output: Box<dyn io::Write> = if profile_output == "-" {
310+
Box::new(io::stdout())
311311
} else {
312-
Box::new(File::create(profile_output)?)
312+
Box::new(fs::File::create(profile_output)?)
313313
};
314314

315+
let profile_output = io::BufWriter::new(profile_output);
316+
315317
match profile_format {
316318
ProfileFormat::Html => flame::dump_html(profile_output)?,
317319
ProfileFormat::Text => flame::dump_text_to_writer(profile_output)?,

0 commit comments

Comments
 (0)