Home / File/ throughput.rs — tailwindcss Source File

throughput.rs — tailwindcss Source File

Architecture documentation for throughput.rs, a rust file in the tailwindcss codebase. 1 imports, 0 dependents.

File rust OxideEngine Scanner 1 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  dc7647b3_89f1_fa5f_6bc9_ccda1054127b["throughput.rs"]
  32d0df29_52be_cb16_c3a0_4a75bfcddaaf["std::fmt::Display"]
  dc7647b3_89f1_fa5f_6bc9_ccda1054127b --> 32d0df29_52be_cb16_c3a0_4a75bfcddaaf
  style dc7647b3_89f1_fa5f_6bc9_ccda1054127b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

use std::fmt::Display;

pub struct Throughput {
    rate: f64,
    elapsed: std::time::Duration,
}

impl Display for Throughput {
    #[inline(always)]
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(
            f,
            "{}/s over {:.2}s",
            format_byte_size(self.rate),
            self.elapsed.as_secs_f64()
        )
    }
}

impl Throughput {
    #[inline(always)]
    pub fn compute<F>(iterations: usize, memory_baseline: usize, cb: F) -> Self
    where
        F: Fn(),
    {
        let now = std::time::Instant::now();
        for _ in 0..iterations {
            cb();
        }
        let elapsed = now.elapsed();
        let memory_size = iterations * memory_baseline;

        Self {
            rate: memory_size as f64 / elapsed.as_secs_f64(),
            elapsed,
        }
    }
}

#[inline(always)]
fn format_byte_size(size: f64) -> String {
    let units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
    let unit = 1000;
    let mut size = size;
    let mut i = 0;
    while size > unit as f64 {
        size /= unit as f64;
        i += 1;
    }

    format!("{:.2} {}", size, units[i])
}

Domain

Subdomains

Dependencies

  • std::fmt::Display

Frequently Asked Questions

What does throughput.rs do?
throughput.rs is a source file in the tailwindcss codebase, written in rust. It belongs to the OxideEngine domain, Scanner subdomain.
What functions are defined in throughput.rs?
throughput.rs defines 3 function(s): compute, fmt, format_byte_size.
What does throughput.rs depend on?
throughput.rs imports 1 module(s): std::fmt::Display.
Where is throughput.rs in the architecture?
throughput.rs is located at crates/oxide/src/throughput.rs (domain: OxideEngine, subdomain: Scanner, directory: crates/oxide/src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free