Skip to content

Instantly share code, notes, and snippets.

@ball-hayden
Last active January 15, 2020 10:46
Show Gist options
  • Save ball-hayden/5ab0171ee76cd9b0b256b45f7e631b43 to your computer and use it in GitHub Desktop.
Save ball-hayden/5ab0171ee76cd9b0b256b45f7e631b43 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Requires GNU time (gtime)
gtime -v ruby faraday-memory-leak.rb 2> /tmp/benchmark
cat /tmp/benchmark | grep "Maximum resident set size"
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
@ball-hayden
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment