aboutsummaryrefslogtreecommitdiffstats
path: root/components/profile_traits/time.rs
diff options
context:
space:
mode:
authorConnor Imes <connor.k.imes@gmail.com>2015-07-28 15:23:57 -0500
committerConnor Imes <connor.k.imes@gmail.com>2015-09-09 13:35:21 -0500
commit3c25f47dbcfd39396298fdd9f229305676836118 (patch)
treef1bf48e6094cb53d03b9769e5f34cf041f1cfb55 /components/profile_traits/time.rs
parent0d37e8f96b7f40d14bf4fbb0b66e42a01302a336 (diff)
downloadservo-3c25f47dbcfd39396298fdd9f229305676836118.tar.gz
servo-3c25f47dbcfd39396298fdd9f229305676836118.zip
Add energy monitoring and characterization scripts
Diffstat (limited to 'components/profile_traits/time.rs')
-rw-r--r--components/profile_traits/time.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/components/profile_traits/time.rs b/components/profile_traits/time.rs
index 81eab5faacb..681c171d449 100644
--- a/components/profile_traits/time.rs
+++ b/components/profile_traits/time.rs
@@ -5,6 +5,7 @@
extern crate time as std_time;
extern crate url;
+use energy::read_energy_uj;
use ipc_channel::ipc::IpcSender;
use self::std_time::precise_time_ns;
use self::url::Url;
@@ -29,7 +30,7 @@ impl ProfilerChan {
#[derive(Clone, Deserialize, Serialize)]
pub enum ProfilerMsg {
/// Normal message used for reporting time
- Time((ProfilerCategory, Option<TimerMetadata>), (u64, u64)),
+ Time((ProfilerCategory, Option<TimerMetadata>), (u64, u64), (u64, u64)),
/// Message used to force print the profiling metrics
Print,
/// Tells the profiler to shut down.
@@ -72,6 +73,7 @@ pub enum ProfilerCategory {
ScriptWebSocketEvent,
ScriptWorkerEvent,
ScriptXhrEvent,
+ ApplicationHeartbeat,
}
#[derive(Eq, PartialEq)]
@@ -96,15 +98,19 @@ pub fn profile<T, F>(category: ProfilerCategory,
-> T
where F: FnOnce() -> T
{
+ let start_energy = read_energy_uj();
let start_time = precise_time_ns();
let val = callback();
let end_time = precise_time_ns();
+ let end_energy = read_energy_uj();
let meta = meta.map(|(url, iframe, reflow_type)|
TimerMetadata {
url: url.serialize(),
iframe: iframe == TimerMetadataFrameType::IFrame,
incremental: reflow_type == TimerMetadataReflowType::Incremental,
});
- profiler_chan.send(ProfilerMsg::Time((category, meta), (start_time, end_time)));
+ profiler_chan.send(ProfilerMsg::Time((category, meta),
+ (start_time, end_time),
+ (start_energy, end_energy)));
return val;
}