The sensor-w1therm utility from the WildlifeSystems project has been
rewritten from Bash to C to improve start-up time, and provide more
efficient sensor readings on Raspberry Pi devices. This report analyses
benchmark results comparing the performance of the new C implementation
(sensor-w1therm) against the old Bash-based implementation
(sensor-ds18b20).
The DS18B20 is a commonly used 1-Wire temperature sensor, and the ability to read multiple sensors efficiently is important for environmental monitoring applications. The WildlifeSystems project uses these sensors for continuous temperature monitoring across multiple nodes.
The source code is available at github.com/Wildlife-Systems/sensor-w1therm.
The DS18B20 is a digital temperature sensor that uses the 1-Wire protocol, allowing multiple sensors to be connected on a single data line. Each sensor has a unique 64-bit ROM code, enabling individual addressing on a shared bus.
Key characteristics:
w1-therm)The Linux kernel provides native support for 1-Wire devices through
the w1 subsystem. The w1-therm driver exposes
temperature readings via sysfs, making sensor access straightforward
from user-space.
The benchmark measures the total end-to-end execution time of invoking each binary, including process startup, library loading, sensor reading, and JSON output generation. This reflects real-world usage where the binary is called by an external scheduler.
Tests were conducted with two configurations:
For each configuration:
/usr/bin/time)This section compares the performance when reading a single DS18B20 sensor.
| Implementation | Mean Real Time (s) | Median Real Time (s) | SD Real Time (s) | Mean User Time (s) | Mean Sys Time (s) | Success Rate |
|---|---|---|---|---|---|---|
| C (w1therm) | 0.8283 | 0.82 | 0.0749 | 0.0000 | 0.0301 | 100% |
| Bash (ds18b20) | 0.9566 | 0.95 | 0.0709 | 0.0217 | 0.1545 | 100% |
Key finding: With a single sensor, the C implementation averages 0.83 seconds per invocation compared to 0.96 seconds for Bash — a 1.15× speedup.


The dominant time component for both implementations is I/O wait (waiting for the sensor to complete its temperature conversion). However, the Bash implementation adds overhead in user-space CPU time for shell interpreter loading.
This section compares the performance when reading four DS18B20 sensors on the same 1-Wire bus.
| Implementation | Mean Real Time (s) | Median Real Time (s) | SD Real Time (s) | Mean User Time (s) | Mean Sys Time (s) | Success Rate |
|---|---|---|---|---|---|---|
| C (w1therm) | 0.9239 | 0.88 | 0.1628 | 0.0004 | 0.0992 | 100% |
| Bash (ds18b20) | 2.1214 | 2.27 | 0.6454 | 0.1321 | 0.7092 | 100% |
Key finding: With four sensors, the C implementation averages 0.92 seconds per invocation compared to 2.12 seconds for Bash — a 2.30× speedup.


With four sensors, the I/O wait time increases as each sensor must complete its conversion. The C implementation handles multiple sensors significantly more efficiently than Bash.
This section examines how performance scales from one to four sensors.

Scaling observations:
To select an appropriate statistical test, we assess normality using the Shapiro-Wilk test:
Single Sensor:
Four Sensors:
Given the potential for non-normal distributions, we use the non-parametric Wilcoxon rank-sum test.
Both comparisons show statistically significant differences between the implementations (p < 0.05).
The benchmark results demonstrate significant performance
improvements from migrating sensor-ds18b20 (Bash) to
sensor-w1therm (C):
Based on 100 invocations:
Based on 100 invocations:
The C implementation shows dramatic reductions in CPU overhead:
| Metric | C (w1therm) | Bash (ds18b20) |
|---|---|---|
| Mean User CPU (1 sensor) | 0.000s | 0.022s |
| Mean Sys CPU (1 sensor) | 0.030s | 0.154s |
| Mean User CPU (4 sensors) | 0.000s | 0.132s |
| Mean Sys CPU (4 sensors) | 0.099s | 0.709s |
These results validate the migration from Bash
(sensor-ds18b20) to C (sensor-w1therm) for
DS18B20 temperature sensor reading. The C implementation provides:
Example annual impact: For a network with 25 DS18B20 sensors reading once per minute (13,140,000 reads per year), the C implementation saves approximately 19.5 days of wall-clock time and 22.2 days of CPU time annually.