-
Notifications
You must be signed in to change notification settings - Fork 127
/
load_sim.rb
39 lines (32 loc) · 949 Bytes
/
load_sim.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
$: << ::File.expand_path("../lib/", __FILE__)
require "rubygems"
require "bundler/setup"
require 'mixlib/cli'
require 'redmon'
require 'redis'
class RedmonLoadSimCLI
include Mixlib::CLI
option :redis_url,
:short => '-r URL',
:long => '--redis URL',
:default => 'redis://127.0.0.1:6379',
:description => "The Redis url to load simulated traffic against (default: redis://127.0.0.1:6379, note: password is supported, ie redis://:[email protected]:6379)"
def run
parse_options
redis_options = Redis::Client::DEFAULTS || {}
redis_options[:url] = config[:redis_url] if config[:redis_url]
redis = Redis.new(redis_options)
loop do
start = rand(100000)
multi = rand(5)
start.upto(multi * start) do |i|
redis.set("key-#{i}", "abcdedghijklmnopqrstuvwxyz")
end
start.upto(multi * start) do |i|
redis.get("key-#{i}")
redis.del("key-#{i}")
end
end
end
end
RedmonLoadSimCLI.new.run