Last active
January 15, 2020 10:46
-
-
Save ball-hayden/5ab0171ee76cd9b0b256b45f7e631b43 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
#!/bin/sh | |
# Requires GNU time (gtime) | |
gtime -v ruby faraday-memory-leak.rb 2> /tmp/benchmark | |
cat /tmp/benchmark | grep "Maximum resident set size" |
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
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'faraday', '<1.0.0' | |
end | |
require "faraday" | |
connections = [] | |
ENV["TIMES"].to_i.times do |i| | |
puts i.to_s | |
connection = Faraday.new("https://gstatic.com/generate_204") do |conn| | |
conn.adapter Faraday.default_adapter | |
end | |
connections.push connection | |
connection.get("/generate_204") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TIMES=1 ./benchmark.sh
Maximum resident set size (kbytes): 27080
TIMES=10 ./benchmark.sh
Maximum resident set size (kbytes): 35132
TIMES=100 ./benchmark.sh
Maximum resident set size (kbytes): 121972