[PATCH] Change min/max to float numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Make min/max consistent with avg by recording the latency samples
as float numbers instead of integers.

Signed-off-by: Rafael Folco <rfolco@xxxxxxxxxx>
---
 src/oslat/oslat.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
index 9e5a08a..6d4a9cb 100644
--- a/src/oslat/oslat.c
+++ b/src/oslat/oslat.c
@@ -159,9 +159,9 @@ struct thread {
 	stamp_t              frc_stop;
 	cycles_t             runtime;
 	stamp_t              *buckets;
-	uint64_t             minlat;
+	double               minlat;
 	/* Maximum latency detected */
-	uint64_t             maxlat;
+	double               maxlat;
 	/*
 	 * The extra part of the interruptions that cannot be put into even the
 	 * biggest bucket.  We'll use this to calculate a more accurate average at
@@ -330,12 +330,11 @@ static float cycles_to_sec(const struct thread *t, uint64_t cycles)
 static void insert_bucket(struct thread *t, stamp_t value)
 {
 	int index;
-	unsigned int lat;
 	uint64_t extra;
-	double us;
+	double lat, us;
 
-	lat = (value * g.unit_per_us) / t->counter_mhz;
-	us = (double)lat / g.unit_per_us;
+	lat = (double)(value * g.unit_per_us) / t->counter_mhz;
+	us = lat / g.unit_per_us;
 	if (!g.preheat && g.trace_threshold && us >= g.trace_threshold) {
 		char *line = "%s: Trace threshold (%d us) triggered on cpu %d with %.*f us!\n";
 		tracemark(line, g.app_name, g.trace_threshold, t->core_i,
@@ -526,10 +525,10 @@ static void write_summary(struct thread *t)
 			 (j == g.bucket_size - 1) ? " (including overflows)" : "");
 	}
 
-	putfieldp("Minimum", t[i].minlat, " (us)");
+	putfield("Minimum", t[i].minlat, ".3lf", " (us)");
 	putfield("Average", t[i].average, ".3lf", " (us)");
-	putfieldp("Maximum", t[i].maxlat, " (us)");
-	putfieldp("Max-Min", t[i].maxlat - t[i].minlat, " (us)");
+	putfield("Maximum", t[i].maxlat, ".3lf", " (us)");
+	putfield("Max-Min", t[i].maxlat - t[i].minlat, ".3lf", " (us)");
 	putfield("Duration", cycles_to_sec(&(t[i]), t[i].runtime),
 		 ".3f", " (sec)");
 	printf("\n");
@@ -547,9 +546,9 @@ static void write_summary_json(FILE *f, void *data)
 		fprintf(f, "    \"%lu\": {\n", i);
 		fprintf(f, "      \"cpu\": %d,\n", t[i].core_i);
 		fprintf(f, "      \"freq\": %d,\n", t[i].counter_mhz);
-		fprintf(f, "      \"min\": %" PRIu64 ",\n", t[i].minlat);
+		fprintf(f, "      \"min\": %3lf,\n", t[i].minlat);
 		fprintf(f, "      \"avg\": %3lf,\n", t[i].average);
-		fprintf(f, "      \"max\": %" PRIu64 ",\n", t[i].maxlat);
+		fprintf(f, "      \"max\": %3lf,\n", t[i].maxlat);
 		fprintf(f, "      \"duration\": %.3f,\n",
 			cycles_to_sec(&(t[i]), t[i].runtime));
 		fprintf(f, "      \"histogram\": {");
-- 
2.47.1





[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux