mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00: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 => {
|
||||
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
|
||||
}
|
||||
};
|
||||
|
|
|
@ -37,6 +37,7 @@ pub fn init() {
|
|||
maybe_create_heartbeat(&mut hbs, ProfilerCategory::PaintingPrepBuff);
|
||||
maybe_create_heartbeat(&mut hbs, ProfilerCategory::Painting);
|
||||
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::ScriptConstellationMsg);
|
||||
maybe_create_heartbeat(&mut hbs, ProfilerCategory::ScriptDevtoolsMsg);
|
||||
|
|
|
@ -97,6 +97,7 @@ impl Formattable for ProfilerCategory {
|
|||
ProfilerCategory::PaintingPrepBuff => "Buffer Prep",
|
||||
ProfilerCategory::Painting => "Painting",
|
||||
ProfilerCategory::ImageDecoding => "Image Decoding",
|
||||
ProfilerCategory::ImageSaving => "Image Saving",
|
||||
ProfilerCategory::ScriptAttachLayout => "Script Attach Layout",
|
||||
ProfilerCategory::ScriptConstellationMsg => "Script Constellation Msg",
|
||||
ProfilerCategory::ScriptDevtoolsMsg => "Script Devtools Msg",
|
||||
|
|
|
@ -57,6 +57,7 @@ pub enum ProfilerCategory {
|
|||
PaintingPrepBuff,
|
||||
Painting,
|
||||
ImageDecoding,
|
||||
ImageSaving,
|
||||
ScriptAttachLayout,
|
||||
ScriptConstellationMsg,
|
||||
ScriptDevtoolsMsg,
|
||||
|
|
|
@ -37,6 +37,7 @@ HEARTBEAT_PROFILER_CATEGORIES = [
|
|||
("PaintingPrepBuff", HEARTBEAT_DEFAULT_WINDOW_SIZE),
|
||||
("Painting", HEARTBEAT_DEFAULT_WINDOW_SIZE),
|
||||
("ImageDecoding", HEARTBEAT_DEFAULT_WINDOW_SIZE),
|
||||
("ImageSaving", HEARTBEAT_DEFAULT_WINDOW_SIZE),
|
||||
("ScriptAttachLayout", HEARTBEAT_DEFAULT_WINDOW_SIZE),
|
||||
("ScriptConstellationMsg", HEARTBEAT_DEFAULT_WINDOW_SIZE),
|
||||
("ScriptDevtoolsMsg", HEARTBEAT_DEFAULT_WINDOW_SIZE),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue