Permalink
Browse files

Improved File Size script

  • Loading branch information...
1 parent 4b2f5e7 commit 19929ecfb5e36d2928b07a7939fe524f71ed360d @wagenet wagenet committed Apr 22, 2012
Showing with 12 additions and 5 deletions.
  1. +12 −5 { → scripts}/list_file_sizes.rb
@@ -18,19 +18,26 @@ def gzip(string)
end
-string = ""
+all_files = ""
+sizes = []
files.each do |file|
this_file = File.read(file)
- string += this_file
+ all_files += this_file
size = this_file.size
uglified = uglify(this_file)
gzipped = gzip(uglified)
+ sizes << [size, uglified.size, gzipped.size, file]
+end
+
+# HEADER
+puts " RAW MIN MIN+GZ"
- puts "%8d %8d %8d - %s" % [size, uglified.size, gzipped.size, file]
+sizes.sort{|a,b| b[2] <=> a[2] }.each do |size|
+ puts "%8d %8d %8d - %s" % size
end
-uglified = uglify(string)
+uglified = uglify(all_files)
gzipped = gzip(uglified)
-puts "%8d %8d %8d" % [string.size, uglified.size, gzipped.size]
+puts "%8d %8d %8d" % [all_files.size, uglified.size, gzipped.size]

0 comments on commit 19929ec

Please sign in to comment.