diff --git a/tools/memcached_ping.rb b/tools/memcached_ping.rb new file mode 100755 index 00000000000..ae4d9973603 --- /dev/null +++ b/tools/memcached_ping.rb @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +require 'dalli' +require 'benchmark' + +server_host = ENV.fetch("MEMCACHED_SERVICE_HOST", "localhost") +server_port = ENV.fetch("MEMCACHED_SERVICE_PORT", "11211") +server_address = "#{server_host}:#{server_port}" + +begin + client = Dalli::Client.new(server_address) + avg = 10.times.map { Benchmark.realtime { client.get("test") } }.inject(:+) / 10.0 + + puts "Average: #{avg.round(8)} seconds" +rescue => err + puts "Failed: #{err}" +end