aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Brubeck <mbrubeck@limpet.net>2016-05-09 09:43:13 -0700
committerMatt Brubeck <mbrubeck@limpet.net>2016-05-09 09:43:13 -0700
commit9b23cf537e7ffa24efbb847af3cc03bad3cb74f8 (patch)
tree5fb1b53718f66e8d8e1018cf397da045b7be56ba
parent47c28586470982a3bc81d774cece3280ab692faa (diff)
downloadservo-9b23cf537e7ffa24efbb847af3cc03bad3cb74f8.tar.gz
servo-9b23cf537e7ffa24efbb847af3cc03bad3cb74f8.zip
Profile time spent saving the screenshot image
-rw-r--r--components/compositing/compositor.rs26
-rw-r--r--components/profile/heartbeats.rs1
-rw-r--r--components/profile/time.rs1
-rw-r--r--components/profile_traits/time.rs1
-rw-r--r--tests/heartbeats/characterize.py1
5 files changed, 18 insertions, 12 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs
index 35b6c8133b6..eedb11e1233 100644
--- a/components/compositing/compositor.rs
+++ b/components/compositing/compositor.rs
@@ -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
}
};
diff --git a/components/profile/heartbeats.rs b/components/profile/heartbeats.rs
index bd143d1fdb5..90a6ffb13bf 100644
--- a/components/profile/heartbeats.rs
+++ b/components/profile/heartbeats.rs
@@ -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);
diff --git a/components/profile/time.rs b/components/profile/time.rs
index fa02cf51f3d..4348fc4af76 100644
--- a/components/profile/time.rs
+++ b/components/profile/time.rs
@@ -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",
diff --git a/components/profile_traits/time.rs b/components/profile_traits/time.rs
index aa01c68efb8..c9887e85409 100644
--- a/components/profile_traits/time.rs
+++ b/components/profile_traits/time.rs
@@ -57,6 +57,7 @@ pub enum ProfilerCategory {
PaintingPrepBuff,
Painting,
ImageDecoding,
+ ImageSaving,
ScriptAttachLayout,
ScriptConstellationMsg,
ScriptDevtoolsMsg,
diff --git a/tests/heartbeats/characterize.py b/tests/heartbeats/characterize.py
index 5a4e9fef5be..1c4298c9d2a 100644
--- a/tests/heartbeats/characterize.py
+++ b/tests/heartbeats/characterize.py
@@ -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),