monotone-devel
[Top][All Lists]
Advanced

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

[Monotone-devel] Patch


From: Sebastian Spaeth
Subject: [Monotone-devel] Patch
Date: Wed, 13 Apr 2005 15:26:05 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050403)

Hi all, after you already included the "show kbytes when necessary"
patch even before I requested it, I still had a look at that and
improved. Please merge if it's ok.

What does my patch do?

- Before it would always show full kb if bytes is > 16kb.
  I modified it to show kb or MB with one decimal after the comma.
  Importing the monotone  repository looks much nicer now :-).
- Second and orthogonal change: Before it would flush *all* values if
either a new cert is in or 256 bytes of network data were read or 256
bytes were written. That was mighty often! I simply reduced the read
write values to 1024 by default. This is still often enough although it
leads to up to 16 times less display flushes.

Thanks for considering this patch. I can give you access to a net
monotone db if you like that better of course.
spaetz

./monotone diff
#
# patch "netsync.cc"
#  from [04871c9d35e04f3f8ed0d10c6311c643c5f79df1]
#    to [98bb94f9c22a40bc6f826cad62737a7f9bfb9a04]
#
# patch "ui.cc"
#  from [f0e2ff249a83fa8a210f961d773ca560bb281592]
#    to [514ce4b3f2f24fea273f487657ef4698c6590c09]
#
# patch "ui.hh"
#  from [7cdd4335a8fa4b4828470eb69b363792bd0a5ce8]
#    to [b86e734da775c81b1ce9da3ca197456d3f077297]
#
--- netsync.cc
+++ netsync.cc
@@ -2897,8 +2897,8 @@
   session sess(role, client_voice, collections, all_collections, app,
                address(), server.get_socketfd(), timeout);

-  sess.byte_in_ticker.reset(new ticker("bytes in", ">", 256, true));
-  sess.byte_out_ticker.reset(new ticker("bytes out", "<", 256, true));
+  sess.byte_in_ticker.reset(new ticker("bytes in", ">", 1024, true));
+  sess.byte_out_ticker.reset(new ticker("bytes out", "<", 1024, true));
   if (role == sink_role)
     {
       sess.cert_in_ticker.reset(new ticker("certs in", "c", 3));
--- ui.cc
+++ ui.cc
@@ -84,15 +84,28 @@
        i != ui.tickers.end(); ++i)
     {
       string suffix;
-      int div = 1;
-      if (i->second->kilocount && i->second->ticks >= 10000)
-        {
-          div = 1024;
-          suffix = "k";
+      ostringstream disptick;
+      if (i->second->kilocount)
+        { // automatic unit conversion is enabled
+          float div;
+          if (i->second->ticks >= 1048576) {
+          // ticks >=1MB, use Mb
+            div = 1048576;
+            suffix = "M";
+          } else {
+          // ticks <1MB, use kb
+            div = 1024;
+            suffix = "k";
+          }
+          disptick << std::fixed << std::setprecision(1) <<
+              (i->second->ticks / div);
+        } else {
+          // no automatic unit conversion.
+          disptick << i->second->ticks;
         }
       tickline +=
         string(" [")
-        + i->first + ": " + lexical_cast<string>(i->second->ticks / div)
+        + i->first + ": " + disptick.str()
         + suffix
         + "]";
     }
--- ui.hh
+++ ui.hh
@@ -13,6 +13,7 @@
 #include <map>
 #include <set>
 #include <string>
+#include <iomanip>
 #include <boost/format.hpp>

 struct user_interface;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]