Skip to content

Instantly share code, notes, and snippets.

@rottenbytes
Last active December 16, 2015 13:49
Show Gist options
  • Save rottenbytes/5444572 to your computer and use it in GitHub Desktop.
Save rottenbytes/5444572 to your computer and use it in GitHub Desktop.
require "rubygems"
require "couchbase"
require "net/http"
require "json"
def random_string(size=30)
#o = [('a'..'z'),('A'..'Z'),(1..9)].map{|i| i.to_a}.flatten
o = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", 1, 2, 3, 4, 5, 6, 7, 8, 9]
string = (0..size).map{ o[rand(o.length)] }.join
end
def get_stats(address)
# display : nb docs / RAM used / Disk used
uri = URI.parse(address)
data = JSON.parse(Net::HTTP.get_response(uri).body)
puts "nb_docs = #{data[0]["basicStats"]["itemCount"]} / memory used = #{data[0]["basicStats"]["memUsed"] / 1024 / 1024 }M / disk used #{data[0]["basicStats"]["diskUsed"] / 1024 / 1024}M"
end
key_size = 52
doc_size = 30
client = Couchbase.connect(:bucket => "uberbucket", :hostname => "10.231.40.11")
get_stats("http://10.231.40.11:8091/pools/default/buckets")
100.times do
docs = Hash.new
100000.times do
doc = random_string(30)
key = random_string(52)
docs[key] = doc
end
client.add(docs)
get_stats("http://10.231.40.11:8091/pools/default/buckets")
end
get_stats("http://10.231.40.11:8091/pools/default/buckets")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment