Hiroshi Hatake
null+****@clear*****
Fri Dec 26 19:11:14 JST 2014
Hiroshi Hatake 2014-12-26 19:11:14 +0900 (Fri, 26 Dec 2014) New Revision: 331b0795de3c88e591dc00230beabe2fa669bd11 https://github.com/groonga/benchmarks/commit/331b0795de3c88e591dc00230beabe2fa669bd11 Message: Import benchmark script Added files: bench_reference_vector.rb Added: bench_reference_vector.rb (+64 -0) 100755 =================================================================== --- /dev/null +++ bench_reference_vector.rb 2014-12-26 19:11:14 +0900 (5a296a7) @@ -0,0 +1,64 @@ +#!/usr/bin/env ruby + +def random_tag + random_tag = (0...8).map{ (65 + rand(26)).chr }.join + random_tag +end + +def known_tags + ["Groonga", "full text search", "C Lang", "mruby", "Text", "MySQL", "Ruby", "C++", + "OSS", "Javascript", "Storage Engine", "binding", "nodejs", "Mroonga", + "Rroonga", "Nroonga", "Droonga", "Distributed"] +end + +def get_known_tags + tags = [] + 5.times do + tags << known_tags.sample + end + tags +end + +def get_unknown_tags + unknown_tags = [] + 5.times do + unknown_tags << random_tag + end + unknown_tags +end + +def article_tags + article_tags = get_known_tags + article_tags.concat(get_unknown_tags) + article_tags +end + +def create_table + print(<<-EOH.strip) +table_create Tags TABLE_HASH_KEY ShortText +table_create Articles TABLE_HASH_KEY ShortText +column_create Articles tags COLUMN_VECTOR Tags +load --table Articles +[ +EOH +end + +def load_data(num_loop) + num_loop.times.each do |i| + print(<<-EOH.strip) +{"_key": "http://groonga.org/", "tags": "#{article_tags}"}, +{"_key": "http://mroonga.org/", "tags": "#{article_tags}"}, +{"_key": "http://ranguba.org/", "tags": "#{article_tags}"}, +{"_key": "http://droonga.org/", "tags": "#{article_tags}"}, +{"_key": "http://nroonga.github.io/", "tags": "#{article_tags}"}, +EOH + end +end + +def eof_data + print("]") +end + +create_table +load_data(10000) +eof_data -------------- next part -------------- HTML����������������������������...Download