Auto merge of #11096 - mbrubeck:profile-image-saving, r=metajack

Profile time spent saving the screenshot image

I did this to see if it was a significant factor in automated test runs.  (Spoiler: it isn't.)

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11096)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-05-09 10:21:00 -07:00
commit 7b8bb0c248
5 changed files with 18 additions and 12 deletions

View file

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