Project

General

Profile

Bug #8998 » ojram.rb

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

 
1
#!/usr/bin/env ruby
2

    
3
require 'oj'
4

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

    
10
last_size_char = ARGV[0][-1]
11
if input_mult = suffixes[last_size_char]
12
  input_size = ARGV[0][0...-1].to_i * input_mult
13
else
14
  input_size = ARGV[0].to_i
15
end
16

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

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