mirror of
https://github.com/servo/servo.git
synced 2025-07-25 08:10:21 +01:00
Profile time spent saving the screenshot image
This commit is contained in:
parent
47c2858647
commit
9b23cf537e
5 changed files with 18 additions and 12 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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",
|
||||||
|
|
|
@ -57,6 +57,7 @@ pub enum ProfilerCategory {
|
||||||
PaintingPrepBuff,
|
PaintingPrepBuff,
|
||||||
Painting,
|
Painting,
|
||||||
ImageDecoding,
|
ImageDecoding,
|
||||||
|
ImageSaving,
|
||||||
ScriptAttachLayout,
|
ScriptAttachLayout,
|
||||||
ScriptConstellationMsg,
|
ScriptConstellationMsg,
|
||||||
ScriptDevtoolsMsg,
|
ScriptDevtoolsMsg,
|
||||||
|
|
|
@ -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),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue