pub fn instructions_histogram<S: Into<String>>(
    name: S,
    help: S,
    metrics_registry: &MetricsRegistry,
) -> Histogram {
    fn add_limits(buckets: &mut Vec<NumInstructions>, config: SchedulerConfig) {
        buckets.push(config.max_instructions_per_message);
        buckets.push(config.max_instructions_per_round);
        buckets.push(config.max_instructions_per_install_code);
    }
    let mut buckets: Vec<NumInstructions> = decimal_buckets_with_zero(4, 10)
        .into_iter()
        .map(|x| NumInstructions::from(x as u64))
        .collect();
    // Add buckets for counting no-op and small messages.
    buckets.push(NumInstructions::from(10));
    buckets.push(NumInstructions::from(1000));
    // Add buckets for all known instruction limits.
    let app_subnet_config = SchedulerConfig::application_subnet();
    add_limits(&mut buckets, app_subnet_config.clone());
    add_limits(&mut buckets, SchedulerConfig::verified_application_subnet());
    add_limits(&mut buckets, SchedulerConfig::system_subnet());

    // Add buckets with higher resolution between [round_limit,
    // round_limit+message_limit] for app subnets.
    let round_limit = app_subnet_config.max_instructions_per_round.get();
    let message_limit = app_subnet_config.max_instructions_per_message.get();
    for value in (round_limit..(round_limit + message_limit)).step_by(1_000_000_000) {
        buckets.push(NumInstructions::from(value));
    }

    // Ensure that all buckets are unique.
    buckets.sort_unstable();
    buckets.dedup();
    // Buckets are [0, 10, 1K, 10K, 20K, ...,  10B, 20B, 50B] + [subnet limits]
    metrics_registry.histogram(
        name,
        help,
        buckets.into_iter().map(|x| x.get() as f64).collect(),
    )
}
/// Returns a histogram with buckets appropriate for instructions.
Returns a histogram with buckets appropriate for instructions.
Returns a histogram with buckets appropriate for instructions .
pub fn instructions_histogram<S: Into<String>>(
    name: S,
    help: S,
    metrics_registry: &MetricsRegistry,
) -> Histogram {
    fn add_limits(buckets: &mut Vec<NumInstructions>, config: SchedulerConfig) {
        buckets.push(config.max_instructions_per_message);
        buckets.push(config.max_instructions_per_round);
        buckets.push(config.max_instructions_per_install_code);
    }
    let mut buckets: Vec<NumInstructions> = decimal_buckets_with_zero(4, 10)
        .into_iter()
        .map(|x| NumInstructions::from(x as u64))
        .collect();
    // Add buckets for counting no-op and small messages.
    buckets.push(NumInstructions::from(10));
    buckets.push(NumInstructions::from(1000));
    // Add buckets for all known instruction limits.
    let app_subnet_config = SchedulerConfig::application_subnet();
    add_limits(&mut buckets, app_subnet_config.clone());
    add_limits(&mut buckets, SchedulerConfig::verified_application_subnet());
    add_limits(&mut buckets, SchedulerConfig::system_subnet());
    // Add buckets with higher resolution between [round_limit,
    // round_limit+message_limit] for app subnets.
    let round_limit = app_subnet_config.max_instructions_per_round.get();
    let message_limit = app_subnet_config.max_instructions_per_message.get();
    for value in (round_limit..(round_limit + message_limit)).step_by(1_000_000_000) {
        buckets.push(NumInstructions::from(value));
    }
    // Ensure that all buckets are unique.
    buckets.sort_unstable();
    buckets.dedup();
    // Buckets are [0, 10, 1K, 10K, 20K, ...,  10B, 20B, 50B] + [subnet limits]
    metrics_registry.histogram(
        name,
        help,
        buckets.into_iter().map(|x| x.get() as f64).collect(),
    )
}
pub fn instructions_histogram < S : Into < String > > ( name : S , help : S , metrics_registry : & MetricsRegistry , ) -> Histogram { fn add_limits ( buckets : & mut Vec < NumInstructions > , config : SchedulerConfig ) { buckets . push ( config . max_instructions_per_message ) ; buckets . push ( config . max_instructions_per_round ) ; buckets . push ( config . max_instructions_per_install_code ) ; } let mut buckets : Vec < NumInstructions > = decimal_buckets_with_zero ( 4 , 10 ) . into_iter ( ) . map ( | x | NumInstructions :: from ( x as u64 ) ) . collect ( ) ; // Add buckets for counting no-op and small messages. buckets . push ( NumInstructions :: from ( 10 ) ) ; buckets . push ( NumInstructions :: from ( 1000 ) ) ; // Add buckets for all known instruction limits. let app_subnet_config = SchedulerConfig :: application_subnet ( ) ; add_limits ( & mut buckets , app_subnet_config . clone ( ) ) ; add_limits ( & mut buckets , SchedulerConfig :: verified_application_subnet ( ) ) ; add_limits ( & mut buckets , SchedulerConfig :: system_subnet ( ) ) ; // Add buckets with higher resolution between [round_limit, // round_limit+message_limit] for app subnets. let round_limit = app_subnet_config . max_instructions_per_round . get ( ) ; let message_limit = app_subnet_config . max_instructions_per_message . get ( ) ; for value in ( round_limit .. ( round_limit + message_limit ) ) . step_by ( 1_000_000_000 ) { buckets . push ( NumInstructions :: from ( value ) ) ; } // Ensure that all buckets are unique. buckets . sort_unstable ( ) ; buckets . dedup ( ) ; // Buckets are [0, 10, 1K, 10K, 20K, ...,  10B, 20B, 50B] + [subnet limits] metrics_registry . histogram ( name , help , buckets . into_iter ( ) . map ( | x | x . get ( ) as f64 ) . collect ( ) , ) }
Returns a histogram with buckets appropriate for instructions.
Returns a histogram with buckets appropriate for instructions .
name
S
help
S
metrics_registry
&MetricsRegistry
name
S
help
S
metrics_registry
&MetricsRegistry