DEV Community

Mohsin Rashid
Mohsin Rashid

Posted on

I Built a CLI That Makes Commands Fight and Tells You Who Wins

This is a submission for the GitHub Copilot CLI Challenge

What I Built

clash — a Rust CLI tool that benchmarks commands head-to-head, measuring both execution time and peak memory usage.

Tools like hyperfine only measure time. But when comparing garbage-collected languages (Python, Node.js) against non-GC ones (Rust, C), memory is half the story. clash gives you the full picture:

  • ⏱ Time stats (mean, min, max, std dev) across multiple runs
  • 💾 Peak memory (RSS) tracked in real-time via background thread
  • 📊 Colored bar charts and tables in your terminal
  • 📁 JSON export for CI pipelines
clash "python sort.py" "node sort.js" "sort_rust" --runs 5
Enter fullscreen mode Exit fullscreen mode

Demo

Repo: github.com/mohsinrashid64/clash-cli

git clone https://github.com/mohsinrashid64/clash-cli.git
cd clash-cli
cargo install --path .

# Run the included Python vs Node vs Rust demo
rustc -O -o benchmarks/sort_sum_rust benchmarks/sort_sum.rs
clash "python benchmarks/sort_sum.py" "node benchmarks/sort_sum.js" "benchmarks/sort_sum_rust" --runs 5
Enter fullscreen mode Exit fullscreen mode

clash CLI demo showing Python vs Node.js vs Rust benchmark comparison

Sample codes of Python, Node.js and Rust

clash CLI demo showing Python vs Node.js vs Rust benchmark comparison

The repo includes identical benchmark scripts in all three languages (generate 2M numbers, sort, compute sum) so you can reproduce this instantly. Check the README for more examples across Windows, macOS, and Linux.

My Experience with GitHub Copilot CLI

AI CLI tooling was central to building clash. The biggest wins:

  • Architecture — Went from a vague "performance monitor" idea to a focused benchmark comparator through AI-guided scoping. It picked the right Rust crates (sysinfo, comfy-table, indicatif, owo-colors) and designed the module structure.

  • The hard part — real-time memory tracking — Monitoring peak RSS of a child process requires a background thread polling sysinfo every 30ms with Arc<AtomicU64> for lock-free peak tracking. Getting this cross-platform (especially Windows) would have taken days without AI assistance.

  • Rapid iteration — When sysinfo APIs had changed between versions, the AI diagnosed and fixed it immediately. The entire tool went from idea to polished release build in a single session.

The AI didn't just write code — it acted as a Rust ecosystem expert. That's what made shipping a polished CLI tool in one day actually possible.

Top comments (0)