Guest User

Untitled

a guest
Dec 11th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. def test(server)
  2. time = Time.now
  3. 100000.times do
  4. server.write Digest::MD5.hexdigest(rand.to_s), Digest::MD5.hexdigest(rand.to_s)
  5. end
  6. Time.now - time
  7. end
  8.  
  9. desc "speed test"
  10. task :speedtest => :environment do
  11. redis = ActiveSupport::Cache::RedisStore.new
  12. memcached = ActiveSupport::Cache::MemCacheStore.new Memcached::Rails.new
  13. memcache = ActiveSupport::Cache::MemCacheStore.new
  14.  
  15. puts "============== speed test ================"
  16. puts "RedisStore 100000 sets in #{test(redis)}"
  17. puts "MemCacheSore memcached 100000 sets in #{test(memcached)}"
  18. Memcached.new.flush
  19. puts "MemCacheSore memcache-client 100000 sets in #{test(memcache)}"
  20. end
Add Comment
Please, Sign In to add comment