# bazhenov/tango architecture

> Architecture diagram of the GitHub repository bazhenov/tango, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bazhenov/tango
- Repository: https://github.com/bazhenov/tango

## Overview

##### Main Components

a) Core Framework Components:
- Benchmark Runner Engine
- Dynamic Loading System
- Paired Execution Controller
- Results Analyzer
- Async Runtime Integration (Tokio)
- CLI Interface

b) Supporting Components:
- Data Collection System
- Plotting/Visualization System
- Export/Import Mechanism
- Build System Integration

##### Test Code Processing Flow
- Source Code → Build System → Dynamic Library
- Dynamic Library → Loader → Benchmark Runner

##### Execution Flow
- Benchmark Runner → Paired Execution Controller
- Paired Execution Controller → Results Analyzer
- Results Analyzer → Output Generation

**┌─ User Interface Layer ─────────────────────┐**
- CLI Interface │ Configuration Management   │
- ┴───────────────────────────┘
**┌─ Core Framework Layer ────────────────────────────────┐**
- Benchmark Runner │ Dynamic Loader │ Execution Engine  │
- ┘
**┌─ Analysis Layer ──────────────────────────┐**
- Results Analyzer │ Statistical Processing │
- ┘
**┌─ Output Layer ───────────────────────────┐**
- Data Export │ Plotting │ Report Generator│
- ┘

##### Specific Implementation Details

- Rectangles: Core components
- Hexagons: Integration points (e.g., Tokio runtime)

##### Important Elements to Emphasize

a) Paired Benchmarking Mechanism:
- How two functions are executed simultaneously
- Interleaving execution pattern
- Parallel execution mode

b) Build Integration:
- Connection to Cargo build system
- Dynamic library generation
- Symbol export mechanism

c) Cross-Platform Support:
- Platform-specific components for Linux/macOS/Windows
- Different symbol export mechanisms

##### Technical Details

Annotations for:
- Supported Rust versions (stable/nightly)
- Platform-specific requirements
- Integration points with external tools (gnuplot, cargo-export)
- Performance metrics (1 second, 1 percent, 1 error capability)

##### Notes for Implementation

- Keep the main flow clear and centered
- Related components visually
- Use consistent spacing and alignment
- Version information
- Notes about extensibility points

- Multiple layers and grouping
- Export to common formats
- Text annotations

This system design should effectively communicate both the high-level architecture and the detailed implementation specifics of the Tango.rs benchmarking framework.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef core fill:#e1f5fe,stroke:#01579b
    classDef ui fill:#e8f5e9,stroke:#2e7d32
    classDef analysis fill:#fff3e0,stroke:#ef6c00
    classDef output fill:#f3e5f5,stroke:#7b1fa2
    classDef async fill:#ffebee,stroke:#c62828
    classDef platform fill:#ede7f6,stroke:#4527a0

    %% User Interface Layer
    subgraph UI
        CLI["CLI Interface"]
        Config["Configuration Management"]
    end

    %% Core Framework Layer
    subgraph Core
        Runner["Benchmark Runner"]
        DynLoader["Dynamic Loading System"]
        ExecEngine["Execution Engine"]
        PairExec["Paired Execution Controller"]
    end

    %% Analysis Layer
    subgraph Analysis
        ResultAnalyzer["Results Analyzer"]
        StatProc["Statistical Processing"]
    end

    %% Output Layer
    subgraph Output
        DataExport["Data Export"]
        Plotting["Plotting System"]
        Report["Report Generator"]
    end

    %% Platform Layer
    subgraph Platform
        Linux["Linux Implementation"]
        MacOS["macOS Support"]
        Windows["Windows Support"]
    end

    %% Async Integration
    AsyncRT{{"Async Runtime (Tokio)"}}

    %% Build System
    BuildSys["Build System Integration"]
    TestCode["Source Code"]
    DynLib["Dynamic Library"]

    %% Relationships
    CLI --> Config
    Config --> Runner
    TestCode -.-> BuildSys
    BuildSys -.-> DynLib
    DynLib --> DynLoader
    DynLoader --> Runner
    Runner --> PairExec
    PairExec --> ExecEngine
    ExecEngine --> ResultAnalyzer
    ResultAnalyzer --> StatProc
    StatProc --> DataExport
    DataExport --> Plotting
    DataExport --> Report
    ExecEngine --- AsyncRT
    DynLoader --> Platform
    Platform --- Linux
    Platform --- MacOS
    Platform --- Windows

    %% Click Events
    click CLI "https://github.com/bazhenov/tango/blob/main/tango-bench/src/cli.rs"
    click DynLoader "https://github.com/bazhenov/tango/blob/main/tango-bench/src/dylib.rs"
    click Linux "https://github.com/bazhenov/tango/blob/main/tango-bench/src/linux.rs"
    click Runner "https://github.com/bazhenov/tango/blob/main/tango-bench/benches/tango.rs"
    click Plotting "https://github.com/bazhenov/tango/blob/main/tango-bench/src/plot.gnuplot"
    click BuildSys "https://github.com/bazhenov/tango/blob/main/tango-bench/build.rs"
    click AsyncRT "https://github.com/bazhenov/tango/blob/main/examples/benches/tango-async.rs"

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["UI Elements"]:::ui
        L3["Analysis Tools"]:::analysis
        L4["Output Systems"]:::output
        L5["Async Features"]:::async
        L6["Platform Specific"]:::platform
    end

    %% Apply Classes
    class Runner,DynLoader,ExecEngine,PairExec core
    class CLI,Config ui
    class ResultAnalyzer,StatProc analysis
    class DataExport,Plotting,Report output
    class AsyncRT async
    class Linux,MacOS,Windows platform
```
