mirror of
https://github.com/servo/servo.git
synced 2025-08-01 11:40:30 +01:00
Rename lots of profiling-related things.
------------------------------------------------------------------------ BEFORE AFTER ------------------------------------------------------------------------ util::memory util::mem - heap_size_of - heap_size_of (unchanged) - SizeOf - HeapSizeOf - size_of_excluding_self - heap_size_of_children prof::mem prof::mem - MemoryProfilerChan - ProfilerChan - MemoryReport - Report - MemoryReportsChan - ReportsChan - MemoryReporter - Reporter - MemoryProfilerMsg - ProfilerMsg - {R,UnR}egisterMemoryReporter - {R,UnR}egisterReporter - MemoryProfiler - Prof - ReportsForest - ReportsForest (unchanged) - ReportsTree - ReportsTree (unchanged) - SystemMemoryReporter - SystemReporter prof::time prof::time - TimeProfilerChan - ProfilerChan - TimerMetadata - TimerMetadata (unchanged) - Formatable - Formattable [spelling!] - TimeProfilerMsg - ProfilerMsg - TimeProfilerCategory - ProfilerCategory - TimeProfilerBuckets - ProfilerBuckets - TimeProfiler - Profiler - TimerMetadataFrameType - TimerMetadataFrameType (unchanged) - TimerMetadataReflowType - TimerMetadataReflowType (unchanged) - ProfilerMetadata - ProfilerMetadata (unchanged) In a few places both prof::time and prof::mem are used, and so module-qualification is needed to avoid overlap, e.g. time::Profiler and mem::Profiler. Likewise with std::mem and prof::mem. This is not a big deal.
This commit is contained in:
parent
7f587f6cb5
commit
ce36e574f4
19 changed files with 322 additions and 331 deletions
|
@ -51,7 +51,7 @@ pub mod linked_list;
|
|||
pub mod fnv;
|
||||
pub mod geometry;
|
||||
pub mod logical_geometry;
|
||||
pub mod memory;
|
||||
pub mod mem;
|
||||
pub mod namespace;
|
||||
pub mod opts;
|
||||
pub mod persistent_list;
|
||||
|
|
|
@ -38,11 +38,11 @@ pub fn heap_size_of(ptr: *const c_void) -> usize {
|
|||
// FIXME(njn): it would be nice to be able to derive this trait automatically, given that
|
||||
// implementations are mostly repetitive and mechanical.
|
||||
//
|
||||
pub trait SizeOf {
|
||||
pub trait HeapSizeOf {
|
||||
/// Measure the size of any heap-allocated structures that hang off this value, but not the
|
||||
/// space taken up by the value itself (i.e. what size_of::<T> measures, more or less); that
|
||||
/// space is handled by the implementation of SizeOf for Box<T> below.
|
||||
fn size_of_excluding_self(&self) -> usize;
|
||||
/// space is handled by the implementation of HeapSizeOf for Box<T> below.
|
||||
fn heap_size_of_children(&self) -> usize;
|
||||
}
|
||||
|
||||
// There are two possible ways to measure the size of `self` when it's on the heap: compute it
|
||||
|
@ -60,49 +60,49 @@ pub trait SizeOf {
|
|||
//
|
||||
// However, in the best case, the two approaches should give the same results.
|
||||
//
|
||||
impl<T: SizeOf> SizeOf for Box<T> {
|
||||
fn size_of_excluding_self(&self) -> usize {
|
||||
impl<T: HeapSizeOf> HeapSizeOf for Box<T> {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
// Measure size of `self`.
|
||||
heap_size_of(&**self as *const T as *const c_void) + (**self).size_of_excluding_self()
|
||||
heap_size_of(&**self as *const T as *const c_void) + (**self).heap_size_of_children()
|
||||
}
|
||||
}
|
||||
|
||||
impl SizeOf for String {
|
||||
fn size_of_excluding_self(&self) -> usize {
|
||||
impl HeapSizeOf for String {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
heap_size_of(self.as_ptr() as *const c_void)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: SizeOf> SizeOf for Option<T> {
|
||||
fn size_of_excluding_self(&self) -> usize {
|
||||
impl<T: HeapSizeOf> HeapSizeOf for Option<T> {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
match *self {
|
||||
None => 0,
|
||||
Some(ref x) => x.size_of_excluding_self()
|
||||
Some(ref x) => x.heap_size_of_children()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: SizeOf> SizeOf for Arc<T> {
|
||||
fn size_of_excluding_self(&self) -> usize {
|
||||
(**self).size_of_excluding_self()
|
||||
impl<T: HeapSizeOf> HeapSizeOf for Arc<T> {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
(**self).heap_size_of_children()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: SizeOf> SizeOf for Vec<T> {
|
||||
fn size_of_excluding_self(&self) -> usize {
|
||||
impl<T: HeapSizeOf> HeapSizeOf for Vec<T> {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
heap_size_of(self.as_ptr() as *const c_void) +
|
||||
self.iter().fold(0, |n, elem| n + elem.size_of_excluding_self())
|
||||
self.iter().fold(0, |n, elem| n + elem.heap_size_of_children())
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(njn): We can't implement SizeOf accurately for LinkedList because it requires access to the
|
||||
// private Node type. Eventually we'll want to add SizeOf (or equivalent) to Rust itself. In the
|
||||
// meantime, we use the dirty hack of transmuting LinkedList into an identical type (LinkedList2) and
|
||||
// measuring that.
|
||||
impl<T: SizeOf> SizeOf for LinkedList<T> {
|
||||
fn size_of_excluding_self(&self) -> usize {
|
||||
// FIXME(njn): We can't implement HeapSizeOf accurately for LinkedList because it requires access
|
||||
// to the private Node type. Eventually we'll want to add HeapSizeOf (or equivalent) to Rust
|
||||
// itself. In the meantime, we use the dirty hack of transmuting LinkedList into an identical type
|
||||
// (LinkedList2) and measuring that.
|
||||
impl<T: HeapSizeOf> HeapSizeOf for LinkedList<T> {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
let list2: &LinkedList2<T> = unsafe { transmute(self) };
|
||||
list2.size_of_excluding_self()
|
||||
list2.heap_size_of_children()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,21 +124,21 @@ struct Node<T> {
|
|||
value: T,
|
||||
}
|
||||
|
||||
impl<T: SizeOf> SizeOf for Node<T> {
|
||||
// Unlike most size_of_excluding_self() functions, this one does *not* measure descendents.
|
||||
// Instead, LinkedList2<T>::size_of_excluding_self() handles that, so that it can use iteration
|
||||
impl<T: HeapSizeOf> HeapSizeOf for Node<T> {
|
||||
// Unlike most heap_size_of_children() functions, this one does *not* measure descendents.
|
||||
// Instead, LinkedList2<T>::heap_size_of_children() handles that, so that it can use iteration
|
||||
// instead of recursion, which avoids potentially blowing the stack.
|
||||
fn size_of_excluding_self(&self) -> usize {
|
||||
self.value.size_of_excluding_self()
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
self.value.heap_size_of_children()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: SizeOf> SizeOf for LinkedList2<T> {
|
||||
fn size_of_excluding_self(&self) -> usize {
|
||||
impl<T: HeapSizeOf> HeapSizeOf for LinkedList2<T> {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
let mut size = 0;
|
||||
let mut curr: &Link<T> = &self.list_head;
|
||||
while curr.is_some() {
|
||||
size += (*curr).size_of_excluding_self();
|
||||
size += (*curr).heap_size_of_children();
|
||||
curr = &curr.as_ref().unwrap().next;
|
||||
}
|
||||
size
|
|
@ -47,7 +47,7 @@ pub struct Opts {
|
|||
|
||||
/// `None` to disable the memory profiler or `Some` with an interval in seconds to enable it
|
||||
/// and cause it to produce output on that interval (`-m`).
|
||||
pub memory_profiler_period: Option<f64>,
|
||||
pub mem_profiler_period: Option<f64>,
|
||||
|
||||
/// Enable experimental web features (`-e`).
|
||||
pub enable_experimental: bool,
|
||||
|
@ -176,7 +176,7 @@ pub fn default_opts() -> Opts {
|
|||
tile_size: 512,
|
||||
device_pixels_per_px: None,
|
||||
time_profiler_period: None,
|
||||
memory_profiler_period: None,
|
||||
mem_profiler_period: None,
|
||||
enable_experimental: false,
|
||||
layout_threads: 1,
|
||||
nonincremental_layout: false,
|
||||
|
@ -286,7 +286,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
|
|||
let time_profiler_period = opt_match.opt_default("p", "5").map(|period| {
|
||||
period.parse().unwrap()
|
||||
});
|
||||
let memory_profiler_period = opt_match.opt_default("m", "5").map(|period| {
|
||||
let mem_profiler_period = opt_match.opt_default("m", "5").map(|period| {
|
||||
period.parse().unwrap()
|
||||
});
|
||||
|
||||
|
@ -330,7 +330,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
|
|||
tile_size: tile_size,
|
||||
device_pixels_per_px: device_pixels_per_px,
|
||||
time_profiler_period: time_profiler_period,
|
||||
memory_profiler_period: memory_profiler_period,
|
||||
mem_profiler_period: mem_profiler_period,
|
||||
enable_experimental: opt_match.opt_present("e"),
|
||||
layout_threads: layout_threads,
|
||||
nonincremental_layout: nonincremental_layout,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue