diff options
Diffstat (limited to 'images/benchmarks/ruby/main.rb')
-rwxr-xr-x | images/benchmarks/ruby/main.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/images/benchmarks/ruby/main.rb b/images/benchmarks/ruby/main.rb new file mode 100755 index 000000000..b998f004e --- /dev/null +++ b/images/benchmarks/ruby/main.rb @@ -0,0 +1,27 @@ +require "sinatra" +require "securerandom" +require "redis" + +redis_host = ENV["HOST"] +$redis = Redis.new(host: redis_host) + +def generateText + for i in 0..99 + $redis.set(i, randomBody(1024)) + end +end + +def randomBody(length) + return SecureRandom.alphanumeric(length) +end + +generateText +template = ERB.new(File.read('./index.erb')) + +get "/" do + texts = Array.new + for i in 0..4 + texts.push($redis.get(rand(0..99))) + end + template.result_with_hash(text: texts) +end |