MCPcopy Index your code
hub / github.com/RustPython/RustPython / get_stats

Function get_stats

crates/vm/src/stdlib/gc.rs:132–151  ·  view source on GitHub ↗
(vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

130 /// Return a list of per-generation gc stats.
131 #[pyfunction]
132 fn get_stats(vm: &VirtualMachine) -> PyResult<PyListRef> {
133 let stats = gc_state::gc_state().get_stats();
134 let mut result = Vec::with_capacity(3);
135
136 for stat in stats.iter() {
137 let dict = vm.ctx.new_dict();
138 dict.set_item("collections", vm.ctx.new_int(stat.collections).into(), vm)?;
139 dict.set_item("collected", vm.ctx.new_int(stat.collected).into(), vm)?;
140 dict.set_item(
141 "uncollectable",
142 vm.ctx.new_int(stat.uncollectable).into(),
143 vm,
144 )?;
145 dict.set_item("candidates", vm.ctx.new_int(stat.candidates).into(), vm)?;
146 dict.set_item("duration", vm.ctx.new_float(stat.duration).into(), vm)?;
147 result.push(dict.into());
148 }
149
150 Ok(vm.ctx.new_list(result))
151 }
152
153 /// Return the list of objects tracked by the collector.
154 #[derive(FromArgs)]

Callers

nothing calls this directly

Calls 9

gc_stateFunction · 0.85
get_statsMethod · 0.80
new_dictMethod · 0.80
new_listMethod · 0.80
iterMethod · 0.45
set_itemMethod · 0.45
new_intMethod · 0.45
new_floatMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected