Software /
code /
prosody
Comparison
plugins/mod_admin_telnet.lua @ 9786:00f7af0be849
mod_admin_telnet: sttas:show: Use format option that allows float numbers
string.format("%d", 0.5) causes an error on Lua 5.3
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 16 Jan 2019 14:20:16 +0100 |
parent | 9756:38f7bde4cfe0 |
child | 9868:0361e3379dd1 |
comparison
equal
deleted
inserted
replaced
9785:ff88b03c343f | 9786:00f7af0be849 |
---|---|
1253 local function format_stat(type, value, ref_value) | 1253 local function format_stat(type, value, ref_value) |
1254 ref_value = ref_value or value; | 1254 ref_value = ref_value or value; |
1255 --do return tostring(value) end | 1255 --do return tostring(value) end |
1256 if type == "duration" then | 1256 if type == "duration" then |
1257 if ref_value < 0.001 then | 1257 if ref_value < 0.001 then |
1258 return ("%d µs"):format(value*1000000); | 1258 return ("%g µs"):format(value*1000000); |
1259 elseif ref_value < 0.9 then | 1259 elseif ref_value < 0.9 then |
1260 return ("%0.2f ms"):format(value*1000); | 1260 return ("%0.2f ms"):format(value*1000); |
1261 end | 1261 end |
1262 return ("%0.2f"):format(value); | 1262 return ("%0.2f"):format(value); |
1263 elseif type == "size" then | 1263 elseif type == "size" then |