MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / print_stats

Function print_stats

ciphercore-base/src/bin/ciphercore_inspect.rs:168–277  ·  view source on GitHub ↗
(graph: Graph)

Source from the content-addressed store, hash-verified

166}
167
168pub(crate) fn print_stats(graph: Graph) -> Result<()> {
169 let mut cnt = HashMap::<String, u64>::new();
170 let mut inputs = Vec::<InputInfo>::new();
171 let mut network_traffic_in_bits = 0;
172 let mut total_integer_operations = 0;
173 let mut total_bit_operations = 0;
174 let mut total_8bits_operations = 0;
175 let mut total_16bits_operations = 0;
176 let mut total_32bits_operations = 0;
177 let mut total_64bits_operations = 0;
178 let mut total_128bits_operations = 0;
179 for node in graph.get_nodes() {
180 let op = node.get_operation();
181 let op_name = format!("{op}");
182 *cnt.entry(op_name).or_insert(0) += 1;
183 match op {
184 Operation::Input(_) => {
185 let input = InputInfo {
186 name: node.get_name()?.unwrap_or_else(|| "unnamed".to_owned()),
187 type_string: format!("{}", node.get_type()?),
188 };
189 inputs.push(input);
190 }
191 Operation::NOP => {
192 if is_network_node(node.clone())? {
193 network_traffic_in_bits += get_size_in_bits(node.get_type()?)?;
194 }
195 }
196 Operation::Add
197 | Operation::Subtract
198 | Operation::Multiply
199 | Operation::Dot
200 | Operation::Matmul
201 | Operation::Truncate(_)
202 | Operation::Sum(_) => {
203 let st = node.get_type()?.get_scalar_type();
204 let ops = calculate_integer_operations(node.clone())?;
205 match st {
206 BIT => total_bit_operations += ops,
207 UINT8 | INT8 => total_8bits_operations += ops,
208 UINT16 | INT16 => total_16bits_operations += ops,
209 UINT32 | INT32 => total_32bits_operations += ops,
210 UINT64 | INT64 => total_64bits_operations += ops,
211 UINT128 | INT128 => total_128bits_operations += ops,
212 };
213 total_integer_operations += ops;
214 }
215 _ => {}
216 }
217 }
218 let mut entries: Vec<(String, u64)> = cnt.iter().map(|e| (e.0.clone(), *e.1)).collect();
219 let network_rounds = calculate_network_rounds(graph.clone())?;
220
221 entries.sort_by_key(|e| -(e.1 as i64));
222 println!("-------Stats--------");
223 println!("Inputs: ",);
224 for (i, input) in inputs.iter().enumerate() {
225 println!(" {}. Name:{}", i + 1, input.name);

Callers 1

mainFunction · 0.70

Calls 13

is_network_nodeFunction · 0.85
get_size_in_bitsFunction · 0.85
calculate_network_roundsFunction · 0.85
calculate_ram_statsFunction · 0.85
cloneMethod · 0.80
get_nodesMethod · 0.45
get_operationMethod · 0.45
get_nameMethod · 0.45
pushMethod · 0.45
get_typeMethod · 0.45
get_scalar_typeMethod · 0.45

Tested by

no test coverage detected