On 22/5/25 06:45, Akihiko Odaki wrote:
On 2025/05/22 1:42, Alex Bennée wrote:
It's easy to get lost in zeros while setting the numbers of
instructions per second. Add a scaling suffix to make things simpler.
Signed-off-by: Alex Bennée <alex.ben...@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouv...@linaro.org>
---
v2
- normalise the suffix before a full strcmp0
- check endptr actually set
- fix checkpatch
- scale_entry -> ScaleEntry
- drop hz from suffix
---
contrib/plugins/ips.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/contrib/plugins/ips.c b/contrib/plugins/ips.c
index e5297dbb01..eb4418c25b 100644
--- a/contrib/plugins/ips.c
+++ b/contrib/plugins/ips.c
@@ -129,6 +129,18 @@ static void plugin_exit(qemu_plugin_id_t id, void
*udata)
qemu_plugin_scoreboard_free(vcpus);
}
+typedef struct {
+ const char *suffix;
+ unsigned long multipler;
As I suggested for the previous version, let's use uint32_t or uint64_t.
+} ScaleEntry;
+
+/* a bit like units.h but not binary */
+static
const
ScaleEntry scales[] = {
+ { "k", 1000 },
+ { "m", 1000 * 1000 },
+ { "g", 1000 * 1000 * 1000 },
+};