MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / describe_allocator_event

Function describe_allocator_event

crates/memtrack/tests/stack_tests.rs:13–38  ·  view source on GitHub ↗
(kind: &MemtrackEventKind)

Source from the content-addressed store, hash-verified

11use tempfile::TempDir;
12
13fn describe_allocator_event(kind: &MemtrackEventKind) -> Option<String> {
14 let description = match kind {
15 MemtrackEventKind::Malloc { size, stack_hash } => {
16 format!("Malloc {{ size: {size}, has_stack: {} }}", *stack_hash != 0)
17 }
18 MemtrackEventKind::Calloc { size, stack_hash } => {
19 format!("Calloc {{ size: {size}, has_stack: {} }}", *stack_hash != 0)
20 }
21 MemtrackEventKind::AlignedAlloc { size, stack_hash } => format!(
22 "AlignedAlloc {{ size: {size}, has_stack: {} }}",
23 *stack_hash != 0
24 ),
25 MemtrackEventKind::Realloc {
26 size, stack_hash, ..
27 } => {
28 format!(
29 "Realloc {{ size: {size}, has_stack: {} }}",
30 *stack_hash != 0
31 )
32 }
33 MemtrackEventKind::Free => "Free".to_string(),
34 _ => return None,
35 };
36
37 Some(description)
38}
39
40fn format_events(events: &[MemtrackEvent]) -> Vec<String> {
41 const MARKER: u64 = 0xC0D5_9EED;

Callers 1

format_eventsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected