Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. require 'mysql2'
  2. require 'benchmark'
  3. require "redis"
  4.  
  5. client = Mysql2::Client.new(host: "localhost", username: "root", password: '', database: 'performance_test')
  6. redis = Redis.new
  7.  
  8. Benchmark.bm 10 do |r|
  9. r.report "mysql" do
  10. 10000.times do
  11. client.query('UPDATE steps SET step = step + 1 WHERE user_id = 1;')
  12. end
  13. end
  14.  
  15. r.report "redis" do
  16. 10000.times do
  17. redis.zincrby('steps', 1, "user_1")
  18. end
  19. end
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement