Project

General

Profile

Bug #8998 » ojram.rb

Brett Smith, 04/15/2016 03:58 PM

 
#!/usr/bin/env ruby

require 'oj'

suffixes = {}
"bkmgt".each_char.each_with_index do |suffix, exp|
suffixes[suffix.upcase] = suffixes[suffix] = 1024 ** exp
end

last_size_char = ARGV[0][-1]
if input_mult = suffixes[last_size_char]
input_size = ARGV[0][0...-1].to_i * input_mult
else
input_size = ARGV[0].to_i
end

input_s = "x" * input_size
output_json = Oj.dump(input_s, mode: :compat)

puts "Input: %9d kB" % (input_size / 1024)
open("/proc/self/status").each_line do |line|
print line if (line =~ /^VmPeak:/)
end
(2-2/3)