Is Your Compiler Efficient? This Gauge Can Tell You
Lex built this device that includes a gauge for every core of their CPU in order to evaluate compiler efficiency.
Compiled programming languages, like C++ and Rust, are nice and fast. But compilation can take a long time — especially if you're writing a hefty program. If you're compiling on a computer with a multi-core CPU, the compiler can speed things up by distributing tasks among the cores. But is it doing that efficiently? To find out, Lex built this physical, Task Manager-inspired device that includes a gauge for every core of their CPU.
The purpose of this device is to clearly show how hard each CPU is working at any given time. It also shows RAM and swap memory usage. Lex's computer has a 12-core CPU, so there are 14 individual gauges: one for each CPU core, one for swap memory, and one for RAM. These are analog gauges with moving needles and they are also lit with RGB LEDs, so the colors can also indicate usage (though with less precision than the needles).
An Arduino Mega board controls the needle positions by generating pulse-width modulation (PWM) signals. It also controls the illumination of the WS2812B individually addressable RGB LED strip. The Arduino receives data over serial from Lex's computer, which runs Linux. Lex wrote a simple Rust program that runs in the background, collecting usage data with the systemstat crate and sending it out over serial. That program is lightweight and only consumes a trivial portion of the available resources.
The gauges themselves are standard 5mA models that react to voltage (simulated by PWM) and Lex simply printed new labels to paste inside the housings. Those show the core number, or "mem%" and "swap%" in the case of the final two gauges. The gauges mount onto a frame made from laser-cut acrylic and aluminum rods.
Lex hasn't made the code or schematics available, but experienced makers should be able to use this as inspiration to build their own CPU core-monitoring devices. That could be useful for more than just evaluating compiler efficiency.