Skip to content

Instantly share code, notes, and snippets.

@tgxworld
Created February 2, 2015 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgxworld/d4f1469feeb000478c43 to your computer and use it in GitHub Desktop.
Save tgxworld/d4f1469feeb000478c43 to your computer and use it in GitHub Desktop.
bm_io_file_read_memoy
mem_start = `ps -o rss= -p #{$$}`.to_i
#
# Seek and Read file.
#
require 'tempfile'
max = 200_000
str = "Hello world! " * 1000
f = Tempfile.new('yarv-benchmark')
f.write str
max.times{
f.seek 0
f.read
}
mem_end = `ps -o rss= -p #{$$}`.to_i
puts mem_end - mem_start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment