trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject [12/50] git commit: TS-1853 Fix formatting in logstats to be consistenly 2 decimals
Date Sat, 04 May 2013 15:30:33 GMT
TS-1853 Fix formatting in logstats to be consistenly 2 decimals


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/a8981a71
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/a8981a71
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/a8981a71

Branch: refs/heads/sphinx-docs
Commit: a8981a71ab369bbe603923a52161c8eff7249c3a
Parents: 824fd64
Author: Leif Hedstrom <zwoop@apache.org>
Authored: Fri Apr 26 09:36:45 2013 -0600
Committer: Leif Hedstrom <zwoop@apache.org>
Committed: Fri Apr 26 09:44:59 2013 -0600

----------------------------------------------------------------------
 CHANGES                      |    2 ++
 proxy/logstats.cc            |   13 ++++++-------
 proxy/tests/logstats.summary |   20 ++++++++++----------
 3 files changed, 18 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a8981a71/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index c21c558..9f48947 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
   Changes with Apache Traffic Server 3.3.3
 
 
+  *) [TS-1853] Fix formatting in logstats to be consistenly 2 decimals.
+
   *) [TS-1852] Fix missing AC_PROG_SED on CentOS 5.9.
 
   *) [TS-1717] Fix the static build as much as possible.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a8981a71/proxy/logstats.cc
----------------------------------------------------------------------
diff --git a/proxy/logstats.cc b/proxy/logstats.cc
index 9789316..e99b2e1 100644
--- a/proxy/logstats.cc
+++ b/proxy/logstats.cc
@@ -1797,24 +1797,23 @@ format_elapsed_header()
 inline void
 format_elapsed_line(const char *desc, const ElapsedStats &stat, bool json=false)
 {
-  static char buf[64];
-
   if (json) {
     std::cout << "    " << '"' << desc << "\" : " << "{ ";
     std::cout << "\"min\": \"" << stat.min << "\", ";
     std::cout << "\"max\": \"" << stat.max << "\", ";
     std::cout << "\"avg\": \"" << std::setiosflags(ios::fixed) << std::setprecision(2)
<< stat.avg << "\", ";
-    std::cout << "\"dev\": \"" << std::setiosflags(ios::fixed) << std::setprecision(2)
<< stat.stddev << "\" }," << std::endl;
+    std::cout << "\"dev\": \"" << std::setiosflags(ios::fixed) << std::setprecision(2)
<< stat.stddev << "\" },";
+    std::cout << std::endl;
   } else {
     std::cout << std::left << std::setw(24) << desc;
     std::cout << std::right << std::setw(7);
     format_int(stat.min);
     std::cout << std::right << std::setw(13);
     format_int(stat.max);
-    snprintf(buf, sizeof(buf), "%17.3f", stat.avg);
-    std::cout << std::right << buf;
-    snprintf(buf, sizeof(buf), "%17.3f", stat.stddev);
-    std::cout << std::right << buf << std::endl;
+
+    std::cout << std::right << std::setw(17) << std::setiosflags(ios::fixed)
<< std::setprecision(2) << stat.avg;
+    std::cout << std::right << std::setw(17) << std::setiosflags(ios::fixed)
<< std::setprecision(2) << stat.stddev;
+    std::cout << std::endl;
   }
 }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a8981a71/proxy/tests/logstats.summary
----------------------------------------------------------------------
diff --git a/proxy/tests/logstats.summary b/proxy/tests/logstats.summary
index 21f7fe3..f27077c 100644
--- a/proxy/tests/logstats.summary
+++ b/proxy/tests/logstats.summary
@@ -147,16 +147,16 @@ other                                      0      0.00%      0.00KB
     0.00%
 
 Elapsed time stats          Min          Max              Avg    Std Deviation
 ------------------------------------------------------------------------------
-Cache hit                     0            0            0.000            0.000
-Cache hit IMS                 0            0            0.000            0.000
-Cache hit refresh             0            0            0.000            0.000
-Cache hit other               0            0            0.000            0.000
-Cache hit total               0            0            0.000            0.000
-Cache miss                   88        1,059          449.643          199.972
-Cache miss IMS                0            0            0.000            0.000
-Cache miss refresh          168          491          278.800          117.469
-Cache miss other              0            0            0.000            0.000
-Cache miss total             88        1,059          423.758          199.431
+Cache hit                     0            0             0.00             0.00
+Cache hit IMS                 0            0             0.00             0.00
+Cache hit refresh             0            0             0.00             0.00
+Cache hit other               0            0             0.00             0.00
+Cache hit total               0            0             0.00             0.00
+Cache miss                   88        1,059           449.64           199.97
+Cache miss IMS                0            0             0.00             0.00
+Cache miss refresh          168          491           278.80           117.47
+Cache miss other              0            0             0.00             0.00
+Cache miss total             88        1,059           423.76           199.43
 
 ______________________________________________________________________________
 


Mime
View raw message