Skip to content

Commit

Permalink
add additional filter modes for allocation and alloc count over time
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed Mar 8, 2024
1 parent c6ffc44 commit f7624f1
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions crates/turbopack-trace-server/src/viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub enum ValueMode {
PersistentAllocations,
AllocationCount,
Count,
AllocationsPerTime,
AllocationCountPerTime,
}

impl ValueMode {
Expand All @@ -43,6 +45,24 @@ impl ValueMode {
ValueMode::PersistentAllocations => span.total_persistent_allocations(),
ValueMode::AllocationCount => span.total_allocation_count(),
ValueMode::Count => span.total_span_count(),
ValueMode::AllocationsPerTime => {
let time = span.corrected_total_time();
let allocations = span.total_allocations();
if time == 0 {
0
} else {
allocations / time
}
}
ValueMode::AllocationCountPerTime => {
let time = span.corrected_total_time();
let allocations = span.total_allocation_count();
if time == 0 {
0
} else {
allocations / time
}
}
}
}

Expand All @@ -54,6 +74,24 @@ impl ValueMode {
ValueMode::PersistentAllocations => graph.total_persistent_allocations(),
ValueMode::AllocationCount => graph.total_allocation_count(),
ValueMode::Count => graph.total_span_count(),
ValueMode::AllocationsPerTime => {
let time = graph.corrected_total_time();
let allocations = graph.total_allocations();
if time == 0 {
0
} else {
allocations / time
}
}
ValueMode::AllocationCountPerTime => {
let time = graph.corrected_total_time();
let allocations = graph.total_allocation_count();
if time == 0 {
0
} else {
allocations / time
}
}
}
}

Expand All @@ -65,6 +103,24 @@ impl ValueMode {
ValueMode::PersistentAllocations => event.total_persistent_allocations(),
ValueMode::AllocationCount => event.total_allocation_count(),
ValueMode::Count => event.total_span_count(),
ValueMode::AllocationsPerTime => {
let time = event.corrected_total_time();
let allocations = event.total_allocations();
if time == 0 {
0
} else {
allocations / time
}
}
ValueMode::AllocationCountPerTime => {
let time = event.corrected_total_time();
let allocations = event.total_allocation_count();
if time == 0 {
0
} else {
allocations / time
}
}
}
}

Expand All @@ -76,6 +132,24 @@ impl ValueMode {
ValueMode::PersistentAllocations => bottom_up.self_persistent_allocations(),
ValueMode::AllocationCount => bottom_up.self_allocation_count(),
ValueMode::Count => bottom_up.self_span_count(),
ValueMode::AllocationsPerTime => {
let time = bottom_up.corrected_self_time();
let allocations = bottom_up.self_allocations();
if time == 0 {
0
} else {
allocations / time
}
}
ValueMode::AllocationCountPerTime => {
let time = bottom_up.corrected_self_time();
let allocations = bottom_up.self_allocation_count();
if time == 0 {
0
} else {
allocations / time
}
}
}
}

Expand All @@ -87,6 +161,24 @@ impl ValueMode {
ValueMode::PersistentAllocations => bottom_up_span.self_persistent_allocations(),
ValueMode::AllocationCount => bottom_up_span.self_allocation_count(),
ValueMode::Count => bottom_up_span.self_span_count(),
ValueMode::AllocationsPerTime => {
let time = bottom_up_span.corrected_self_time();
let allocations = bottom_up_span.self_allocations();
if time == 0 {
0
} else {
allocations / time
}
}
ValueMode::AllocationCountPerTime => {
let time = bottom_up_span.corrected_self_time();
let allocations = bottom_up_span.self_allocation_count();
if time == 0 {
0
} else {
allocations / time
}
}
}
}
}
Expand Down Expand Up @@ -300,6 +392,8 @@ impl Viewer {
"deallocations" => ValueMode::Deallocations,
"persistent-deallocations" => ValueMode::PersistentAllocations,
"allocation-count" => ValueMode::AllocationCount,
"allocations-per-time" => ValueMode::AllocationsPerTime,
"allocation-count-per-time" => ValueMode::AllocationCountPerTime,
"count" => ValueMode::Count,
_ => ValueMode::Duration,
};
Expand Down

0 comments on commit f7624f1

Please sign in to comment.