formatDuration function
Implementation
String formatDuration(double ms) {
if (ms < 0.001) {
return '${(ms * 1000000).toStringAsFixed(1)} ns';
} else if (ms < 1.0) {
return '${(ms * 1000).toStringAsFixed(1)} μs';
} else {
return '${ms.toStringAsFixed(2)} ms';
}
}