[m-rev.] diff: deep profiler outpu format improvement

Zoltan Somogyi zs at csse.unimelb.edu.au
Mon Jul 2 20:03:53 AEST 2007


deep_profiler/html_format.m:
	Make the output a bit easier to read by adding commas at every
	power of a thousand in call sequence number counts.

Zoltan.

cvs diff: Diffing .
Index: html_format.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/html_format.m,v
retrieving revision 1.19
diff -u -b -r1.19 html_format.m
--- html_format.m	3 Apr 2007 02:53:13 -0000	1.19
+++ html_format.m	2 Jul 2007 03:28:19 -0000
@@ -1753,11 +1753,11 @@
     (
         ShowCallSeqs = yes,
         CallSeqsSelfHTML =
-            string.format("<TD CLASS=callseqs ALIGN=RIGHT>%i</TD>\n",
-                [i(OwnCallSeqs)]),
+            string.format("<TD CLASS=callseqs ALIGN=RIGHT>%s</TD>\n",
+                [s(commas(OwnCallSeqs))]),
         CallSeqsTotalHTML =
-            string.format("<TD CLASS=callseqs ALIGN=RIGHT>%i</TD>\n",
-                [i(TotalCallSeqs)]),
+            string.format("<TD CLASS=callseqs ALIGN=RIGHT>%s</TD>\n",
+                [s(commas(TotalCallSeqs))]),
         CallSeqsPropSelfHTML =
             string.format("<TD CLASS=callseqs ALIGN=RIGHT>%s</TD>\n",
                 [s(OwnCallSeqsProp)]),
@@ -1775,18 +1775,20 @@
     (
         ShowCallSeqsPerCall = yes,
         ( Calls = 0 ->
-            OwnCallSeqsPerCall = 0.0,
-            TotalCallSeqsPerCall = 0.0
+            OwnCallSeqsPerCall = "N/A",
+            TotalCallSeqsPerCall = "N/A"
         ;
-            OwnCallSeqsPerCall = float(OwnCallSeqs) / float(Calls),
-            TotalCallSeqsPerCall = float(TotalCallSeqs) / float(Calls)
+            OwnCallSeqsPerCall =
+                one_decimal_fraction(float(OwnCallSeqs) / float(Calls)),
+            TotalCallSeqsPerCall =
+                one_decimal_fraction(float(TotalCallSeqs) / float(Calls))
         ),
         CallSeqsPerCallSelfHTML =
-            string.format("<TD CLASS=callseqs ALIGN=RIGHT>%.1f</TD>\n",
-                [f(OwnCallSeqsPerCall)]),
+            string.format("<TD CLASS=callseqs ALIGN=RIGHT>%s</TD>\n",
+                [s(OwnCallSeqsPerCall)]),
         CallSeqsPerCallTotalHTML =
-            string.format("<TD CLASS=callseqs ALIGN=RIGHT>%.1f</TD>\n",
-                [f(TotalCallSeqsPerCall)])
+            string.format("<TD CLASS=callseqs ALIGN=RIGHT>%s</TD>\n",
+                [s(TotalCallSeqsPerCall)])
     ;
         ShowCallSeqsPerCall = no,
         CallSeqsPerCallSelfHTML = "",
@@ -1989,6 +1991,25 @@
     ),
     TimeStr = TimeStr0 ++ Unit.
 
+:- func one_decimal_fraction(float) = string.
+
+one_decimal_fraction(Measure) = Representation :-
+    string.format("%.1f", [f(Measure)], Str0),
+    string.to_char_list(Str0, Chars0),
+    list.reverse(Chars0, RevChars0),
+    (
+        RevChars0 = [Tenth, DecimalPoint | WholeRevChars0],
+        char.is_digit(Tenth)
+        % DecimalPoint = ('.')
+    ->
+        WholeRevChars = add_commas(WholeRevChars0),
+        RevChars = [Tenth, DecimalPoint | WholeRevChars],
+        Chars = list.reverse(RevChars),
+        string.from_char_list(Chars, Representation)
+    ;
+        error("one_decimal_fraction: malformed number")
+    ).
+
 :- func two_decimal_fraction(float) = string.
 
 two_decimal_fraction(Measure) = Representation :-
cvs diff: Diffing notes
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list