]> git.itanic.dy.fi Git - scan-pagemap/commitdiff
analyzer: Remodify the pretty prints
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 4 Jul 2010 13:26:56 +0000 (16:26 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 4 Jul 2010 13:26:56 +0000 (16:26 +0300)
Now there is an adjustable limit when prettifying prints takes
effect. When the number goes above the threshold, the number is
divided to look prettier.

After this change, there is still enough accuracy in the numbers to
keep them meaningful even though they are shrunk dramatically.

Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
analyze.c

index 8baa33016637b6246506bfd080210b9068185817..1c404fb29f029c28598a33c73dc4231b4f4ac941 100644 (file)
--- a/analyze.c
+++ b/analyze.c
@@ -6,18 +6,20 @@
 #include "bintree.h"
 
 #define SI_k   1024ll
-#define SI_M   (1024 * 1024ll)
-#define SI_G   (1025 * 1024 * 1024ll)
+#define SI_M   (SI_k * SI_k)
+#define SI_G   (SI_M * SI_k)
 
+#define PRETTY_THRESH  100
 #define NICE_DIV(a)                                                    \
-       ((a) < SI_k ? (a) :                                             \
-               (a < SI_M ? ((a) / SI_k) :                              \
-                       (a < SI_G ? ((a) / SI_M) : ((a) / SI_G))))
+       ((a) < SI_k * PRETTY_THRESH ? (a) :                             \
+               (a < SI_M * PRETTY_THRESH ? ((a) / SI_k) :              \
+                       (a < SI_G * PRETTY_THRESH ? ((a) / SI_M) :      \
+                               ((a) / SI_G))))
 
-#define NICE_UNIT(a)                                   \
-       ((a) < SI_k ? "" :                              \
-               ((a) < SI_M ? "k" :                     \
-                       ((a) < SI_G ? "M" : "G")))
+#define NICE_UNIT(a)                                                   \
+       ((a) < (SI_k * PRETTY_THRESH) ? "" :                            \
+               ((a) < (SI_G * PRETTY_THRESH) ? "k" :                   \
+                       ((a) < (SI_G * PRETTY_THRESH) ? "M" : "G")))
 
 #define PAGE_TO_NICE(a)                NICE_DIV((long long)a * PAGE_SIZE)
 #define PAGE_TO_NICE_UNIT(a)   NICE_UNIT((long long)a * PAGE_SIZE)