Profile time spent saving the screenshot image

This commit is contained in:
Matt Brubeck 2016-05-09 09:43:13 -07:00
parent 47c2858647
commit 9b23cf537e
5 changed files with 18 additions and 12 deletions

View file

@ -2166,19 +2166,21 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}) })
} }
CompositeTarget::PngFile => { CompositeTarget::PngFile => {
let img = self.draw_img(render_target_info, profile(ProfilerCategory::ImageSaving, None, self.time_profiler_chan.clone(), || {
width, match opts::get().output_file.as_ref() {
height); Some(path) => match File::create(path) {
match opts::get().output_file.as_ref() { Ok(mut file) => {
Some(path) => match File::create(path) { let img = self.draw_img(render_target_info, width, height);
Ok(mut file) => match DynamicImage::ImageRgb8(img).save(&mut file, ImageFormat::PNG) { let dynamic_image = DynamicImage::ImageRgb8(img);
Ok(()) => (), if let Err(e) = dynamic_image.save(&mut file, ImageFormat::PNG) {
Err(e) => error!("Failed to save {} ({}).", path, e), error!("Failed to save {} ({}).", path, e);
}
},
Err(e) => error!("Failed to create {} ({}).", path, e),
}, },
Err(e) => error!("Failed to create {} ({}).", path, e), None => error!("No file specified."),
}, }
None => error!("No file specified."), });
}
None None
} }
}; };

View file

@ -37,6 +37,7 @@ pub fn init() {
maybe_create_heartbeat(&mut hbs, ProfilerCategory::PaintingPrepBuff); maybe_create_heartbeat(&mut hbs, ProfilerCategory::PaintingPrepBuff);
maybe_create_heartbeat(&mut hbs, ProfilerCategory::Painting); maybe_create_heartbeat(&mut hbs, ProfilerCategory::Painting);
maybe_create_heartbeat(&mut hbs, ProfilerCategory::ImageDecoding); maybe_create_heartbeat(&mut hbs, ProfilerCategory::ImageDecoding);
maybe_create_heartbeat(&mut hbs, ProfilerCategory::ImageSaving);
maybe_create_heartbeat(&mut hbs, ProfilerCategory::ScriptAttachLayout); maybe_create_heartbeat(&mut hbs, ProfilerCategory::ScriptAttachLayout);
maybe_create_heartbeat(&mut hbs, ProfilerCategory::ScriptConstellationMsg); maybe_create_heartbeat(&mut hbs, ProfilerCategory::ScriptConstellationMsg);
maybe_create_heartbeat(&mut hbs, ProfilerCategory::ScriptDevtoolsMsg); maybe_create_heartbeat(&mut hbs, ProfilerCategory::ScriptDevtoolsMsg);

View file

@ -97,6 +97,7 @@ impl Formattable for ProfilerCategory {
ProfilerCategory::PaintingPrepBuff => "Buffer Prep", ProfilerCategory::PaintingPrepBuff => "Buffer Prep",
ProfilerCategory::Painting => "Painting", ProfilerCategory::Painting => "Painting",
ProfilerCategory::ImageDecoding => "Image Decoding", ProfilerCategory::ImageDecoding => "Image Decoding",
ProfilerCategory::ImageSaving => "Image Saving",
ProfilerCategory::ScriptAttachLayout => "Script Attach Layout", ProfilerCategory::ScriptAttachLayout => "Script Attach Layout",
ProfilerCategory::ScriptConstellationMsg => "Script Constellation Msg", ProfilerCategory::ScriptConstellationMsg => "Script Constellation Msg",
ProfilerCategory::ScriptDevtoolsMsg => "Script Devtools Msg", ProfilerCategory::ScriptDevtoolsMsg => "Script Devtools Msg",

View file

@ -57,6 +57,7 @@ pub enum ProfilerCategory {
PaintingPrepBuff, PaintingPrepBuff,
Painting, Painting,
ImageDecoding, ImageDecoding,
ImageSaving,
ScriptAttachLayout, ScriptAttachLayout,
ScriptConstellationMsg, ScriptConstellationMsg,
ScriptDevtoolsMsg, ScriptDevtoolsMsg,

View file

@ -37,6 +37,7 @@ HEARTBEAT_PROFILER_CATEGORIES = [
("PaintingPrepBuff", HEARTBEAT_DEFAULT_WINDOW_SIZE), ("PaintingPrepBuff", HEARTBEAT_DEFAULT_WINDOW_SIZE),
("Painting", HEARTBEAT_DEFAULT_WINDOW_SIZE), ("Painting", HEARTBEAT_DEFAULT_WINDOW_SIZE),
("ImageDecoding", HEARTBEAT_DEFAULT_WINDOW_SIZE), ("ImageDecoding", HEARTBEAT_DEFAULT_WINDOW_SIZE),
("ImageSaving", HEARTBEAT_DEFAULT_WINDOW_SIZE),
("ScriptAttachLayout", HEARTBEAT_DEFAULT_WINDOW_SIZE), ("ScriptAttachLayout", HEARTBEAT_DEFAULT_WINDOW_SIZE),
("ScriptConstellationMsg", HEARTBEAT_DEFAULT_WINDOW_SIZE), ("ScriptConstellationMsg", HEARTBEAT_DEFAULT_WINDOW_SIZE),
("ScriptDevtoolsMsg", HEARTBEAT_DEFAULT_WINDOW_SIZE), ("ScriptDevtoolsMsg", HEARTBEAT_DEFAULT_WINDOW_SIZE),