[Jifty-commit] r6263 - in jifty/trunk: bin

Jifty commits jifty-commit at lists.jifty.org
Fri Jan 23 15:24:28 EST 2009


Author: sartak
Date: Fri Jan 23 15:24:28 2009
New Revision: 6263

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/bin/memory_log

Log:
 r78891 at onn:  sartak | 2009-01-23 15:24:14 -0500
 More readable memory delta


Modified: jifty/trunk/bin/memory_log
==============================================================================
--- jifty/trunk/bin/memory_log	(original)
+++ jifty/trunk/bin/memory_log	Fri Jan 23 15:24:28 2009
@@ -18,6 +18,16 @@
 }
 
 for my $hit (sort { $b->[0] <=> $a->[0] } @hits) {
-    print "$hit->[1]: $hit->[0]\n";
+    my $human_readable = sub {
+        my $bytes = shift;
+        return $bytes if $bytes < 1024;
+        return int($bytes / 1024)    . 'KB' if $bytes < 1024 ** 2;
+        return int($bytes / 1024**2) . 'MB' if $bytes < 1024 ** 3;
+        return int($bytes / 1024**3) . 'GB';
+    }->($hit->[0]);
+
+    $human_readable =~ s/^(?!-)/+/; # add leading + if it's not negative
+
+    print "$hit->[1]: $human_readable\n";
 }
 


More information about the Jifty-commit mailing list