From 6daeefa0d8c9fbafa96aa69ace406021ea8d997f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 13 Oct 2017 16:42:37 +0200 Subject: [PATCH] Show average link count in all entries --- bin/core/imag-diagnostics/Cargo.toml | 1 + bin/core/imag-diagnostics/src/main.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/bin/core/imag-diagnostics/Cargo.toml b/bin/core/imag-diagnostics/Cargo.toml index 0cff95b2..68eafc83 100644 --- a/bin/core/imag-diagnostics/Cargo.toml +++ b/bin/core/imag-diagnostics/Cargo.toml @@ -22,4 +22,5 @@ toml-query = "0.4" libimagstore = { version = "0.5.0", path = "../../../lib/core/libimagstore" } libimagrt = { version = "0.5.0", path = "../../../lib/core/libimagrt" } libimagerror = { version = "0.5.0", path = "../../../lib/core/libimagerror" } +libimagentrylink = { version = "0.5.0", path = "../../../lib/entry/libimagentrylink" } diff --git a/bin/core/imag-diagnostics/src/main.rs b/bin/core/imag-diagnostics/src/main.rs index e71e7fe3..77aeb023 100644 --- a/bin/core/imag-diagnostics/src/main.rs +++ b/bin/core/imag-diagnostics/src/main.rs @@ -39,6 +39,7 @@ extern crate toml_query; extern crate libimagrt; extern crate libimagerror; +extern crate libimagentrylink; extern crate libimagstore; use libimagrt::setup::generate_runtime_setup; @@ -46,6 +47,7 @@ use libimagerror::trace::MapErrTrace; use libimagstore::store::FileLockEntry; use libimagstore::iter::get::*; use libimagstore::error::StoreError as Error; +use libimagentrylink::internal::*; use toml::Value; use toml_query::read::TomlValueReadExt; @@ -60,6 +62,7 @@ struct Diagnostic { pub bytecount_content: usize, pub overall_byte_size: usize, pub verified: bool, + pub num_internal_links: usize, } impl<'a> From> for Diagnostic { @@ -82,6 +85,7 @@ impl<'a> From> for Diagnostic { bytecount_content: entry.get_content().as_str().len(), overall_byte_size: entry.to_str().as_str().len(), verified: entry.verify().is_ok(), + num_internal_links: entry.get_internal_links().map(Iterator::count).unwrap_or(0), } } } @@ -111,6 +115,7 @@ fn main() { let mut sum_overall_byte_size = 0; let mut verified_count = 0; let mut unverified_count = 0; + let mut num_internal_links = 0; for diag in diags.iter() { sum_header_sections += diag.header_sections; @@ -125,6 +130,8 @@ fn main() { } else { unverified_count += 1; } + + num_internal_links += diag.num_internal_links; } let n = diags.len(); @@ -139,6 +146,7 @@ fn main() { println!("{} header sections in the average entry", sum_header_sections / n); println!("{} average content bytecount", sum_bytecount_content / n); println!("{} average overall bytecount", sum_overall_byte_size / n); + println!("{} average internal link count per entry", num_internal_links / n); println!("{} verified entries", verified_count); println!("{} unverified entries", unverified_count); }