MCPcopy Create free account
hub / github.com/ddd/gpb / estimate_total

Method estimate_total

src/format/format.rs:377–395  ·  view source on GitHub ↗

Estimate total count of numbers that will be generated

(&self)

Source from the content-addressed store, hash-verified

375
376 /// Estimate total count of numbers that will be generated
377 pub fn estimate_total(&self) -> u64 {
378 let area_code_count = self.selected_area_codes.len() as u64;
379 let numbers_per_area_code = self.max_numbers_per_segment;
380
381 // Calculate the total based on area codes and numbers per area code
382 let total = area_code_count * numbers_per_area_code;
383
384 // If we have an infix filter, adjust the estimate
385 // For an infix of length 2, approximately 1 in 100 numbers will match
386 if let Some(infix) = &self.infix_filter {
387 // Each digit in the infix reduces the probability by a factor of 10
388 let infix_factor = 10_u64.pow(infix.len() as u32);
389
390 // Return the adjusted total, ensuring we don't return zero
391 std::cmp::max(1, total / infix_factor)
392 } else {
393 total
394 }
395 }
396}
397
398#[cfg(test)]

Callers 4

mainFunction · 0.80
process_csv_modeFunction · 0.80
test_infix_filteringFunction · 0.80

Calls

no outgoing calls

Tested by 1

test_infix_filteringFunction · 0.64