-
-
Save stereobooster/1b091f3e1a712649b43691e406059e3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2.3.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
source "https://rubygems.org" | |
gem 'get_process_mem' | |
gem 'rusage' | |
gem 'posix-spawn' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GEM | |
remote: https://rubygems.org/ | |
specs: | |
get_process_mem (0.2.1) | |
posix-spawn (0.3.13) | |
rusage (0.2.0) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
get_process_mem | |
posix-spawn | |
rusage | |
BUNDLED WITH | |
1.16.0.pre.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'get_process_mem' | |
require 'rusage' | |
require 'benchmark' | |
# require 'posix/spawn' | |
memory_bloat = [] | |
10_000.times { memory_bloat.push " "*10_000 } | |
n = 10_000 | |
gpm = GetProcessMem.new | |
Benchmark.bm(10) do |x| | |
x.report("status:") { n.times do gpm.linux_status_memory end } | |
x.report("rusage:") { n.times do Process.rusage.maxrss end } | |
# In sshaw version | |
# x.report("statm:") { n.times do gpm.linux_statm_memory end } | |
# x.report("ps:") { n.times do `ps -o rss= -p #{$$}`.to_f end } | |
# x.report("POSIX::Spawn:") { n.times do POSIX::Spawn.`("ps -o rss= -p #{$$}").to_f end } | |
end | |
puts "GetProcessMem: #{gpm.kb} kb" | |
puts "rusage: #{Process.rusage.maxrss/1024.0} kb" | |
puts "ps: #{`ps -o rss= -p #{$$}`.to_f} kb" | |
puts "oink: #{`ps -o vsz= -p #{$$}`.to_f} kb" # this is what oink measures |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment