diff options
author | Zach Koopmans <zkoopmans@google.com> | 2020-08-07 13:47:03 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-08-07 13:49:07 -0700 |
commit | 7b9bfc0ce094b0fd0cb3beec665a7b64c4ec552e (patch) | |
tree | ee9fcb5a7c0617b41c1d9096a36b9812bc5c4124 /images/benchmarks/ruby/main.rb | |
parent | a7bd0a701289f8d808f93eaded266f6a1bab03ea (diff) |
Port Ruby benchmark.
PiperOrigin-RevId: 325500772
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 |