-
-
Save huacnlee/1150933 to your computer and use it in GitHub Desktop.
redis-search 0.3 Benchmark | |
Core 2 Duo CPU 2.66G, 4G Memory | |
20W 数据 | |
# coding: utf-8 | |
require "benchmark" | |
["的","美丽","云","云儿","花","云儿的"].each do |key| | |
count = RedisSearch::Search.query("Person", key, :limit => 1000000).count | |
puts "="*80 | |
puts "Search #{key} all count:#{count}..." | |
Benchmark.bm do |bm| | |
[1, 10, 100, 1000, 10000].each do |i| | |
bm.report("Search #{i}") do | |
i.times do |n| | |
RedisSearch::Search.query("Person", key, :limit => 20) | |
end | |
end | |
end | |
end | |
end | |
================================================================================ | |
Search 的 all count:5600... | |
user system total real | |
Search 1 0.000000 0.000000 0.000000 ( 0.013436) | |
Search 10 0.010000 0.000000 0.010000 ( 0.017582) | |
Search 100 0.090000 0.010000 0.100000 ( 0.265795) | |
Search 1000 0.430000 0.080000 0.510000 ( 2.152209) | |
Search 10000 4.810000 0.700000 5.510000 ( 20.952217) | |
================================================================================ | |
Search 美丽 all count:456... | |
user system total real | |
Search 1 0.000000 0.000000 0.000000 ( 0.001668) | |
Search 10 0.010000 0.010000 0.020000 ( 0.014248) | |
Search 100 0.040000 0.010000 0.050000 ( 0.144137) | |
Search 1000 0.540000 0.120000 0.660000 ( 1.301681) | |
Search 10000 5.430000 1.230000 6.660000 ( 13.224271) | |
================================================================================ | |
Search 云 all count:1074... | |
user system total real | |
Search 1 0.000000 0.000000 0.000000 ( 0.001033) | |
Search 10 0.000000 0.000000 0.000000 ( 0.007430) | |
Search 100 0.040000 0.010000 0.050000 ( 0.086030) | |
Search 1000 0.490000 0.060000 0.550000 ( 0.917758) | |
Search 10000 4.790000 0.640000 5.430000 ( 9.161982) | |
================================================================================ | |
Search 云儿 all count:16... | |
user system total real | |
Search 1 0.000000 0.000000 0.000000 ( 0.001236) | |
Search 10 0.000000 0.000000 0.000000 ( 0.010758) | |
Search 100 0.040000 0.010000 0.050000 ( 0.088965) | |
Search 1000 0.500000 0.120000 0.620000 ( 0.965457) | |
Search 10000 4.720000 1.170000 5.890000 ( 9.448613) | |
================================================================================ | |
Search 花 all count:1478... | |
user system total real | |
Search 1 0.000000 0.000000 0.000000 ( 0.001275) | |
Search 10 0.010000 0.000000 0.010000 ( 0.008314) | |
Search 100 0.030000 0.010000 0.040000 ( 0.085385) | |
Search 1000 0.500000 0.060000 0.560000 ( 1.018030) | |
Search 10000 4.860000 0.640000 5.500000 ( 10.057470) | |
================================================================================ | |
Search 云儿的 all count:2... | |
user system total real | |
Search 1 0.000000 0.000000 0.000000 ( 0.000657) | |
Search 10 0.000000 0.000000 0.000000 ( 0.006602) | |
Search 100 0.020000 0.010000 0.030000 ( 0.072634) | |
Search 1000 0.250000 0.120000 0.370000 ( 0.670645) | |
Search 10000 2.100000 1.120000 3.220000 ( 6.350150) | |
平均每秒 2000 次搜索请求 |
code:
keys_count = $redis.dbsize
puts "Complete Benchmark from [CategoryTest], current have (#{keys_count} keys) in Redis"
["c","ca","can","jack"].each do |q|
puts "Search by [#{q}]"
puts " #{'-'*90}"
puts " #{Redis::Search.complete("CategoryTest",q, :limit => 10).collect { |c| c['title'] }}"
puts " #{'-'*90}"
puts "There have [#{Redis::Search.complete("CategoryTest",q, :limit => 1000000).count}] items like 'c'"
Benchmark.bm do|bm|
bm.report(" 1 times") do
1.times do |i|
Redis::Search.complete("CategoryTest",q, :limit => 10)
end
end
bm.report(" 10 times") do
10.times do |i|
Redis::Search.complete("CategoryTest",q, :limit => 10)
end
end
bm.report(" 100 times") do
100.times do |i|
Redis::Search.complete("CategoryTest",q, :limit => 10)
end
end
end
puts ""
end
Complete Benchmark from [CategoryTest], current have (997911 keys) in Redis
Search by [c]
------------------------------------------------------------------------------------------
["Caam Atimon", "C Precanonical", "Caama Laicizer", "Caama Rejail", "Ca Squatarole", "Caaming Idolize", "C Sphenophyllales", "Caaming Mercurian", "Caama Delegant", "C Quadrifoliolate"]
------------------------------------------------------------------------------------------
There have [30777] items like 'c'
user system total real
1 times 0.000000 0.000000 0.000000 ( 0.005404)
10 times 0.050000 0.000000 0.050000 ( 0.055414)
100 times 0.380000 0.010000 0.390000 ( 0.448068)
Search by [ca]
------------------------------------------------------------------------------------------
["Caam Atimon", "Caapeba Unnapkined", "Caama Laicizer", "Caaming Voltairian", "Caaming Idolize", "Ca Squatarole", "Caatinga Glossiphonia", "Caama Rejail", "Caaming Mercurian", "Caama Delegant"]
------------------------------------------------------------------------------------------
There have [6543] items like 'ca'
user system total real
1 times 0.000000 0.000000 0.000000 ( 0.005377)
10 times 0.040000 0.000000 0.040000 ( 0.247831)
100 times 0.370000 0.010000 0.380000 ( 0.725490)
Search by [can]
------------------------------------------------------------------------------------------
["Can Zealot", "Canaanite Bistort", "Canaan Unpermeated", "Canaanitic Crupper", "Canaba Lactonic", "Can Mistranslation", "Cana Tua", "Canaan Expungeable", "Canaan Tiponi", "Canaanitic Conocarpus"]
------------------------------------------------------------------------------------------
There have [745] items like 'can'
user system total real
1 times 0.000000 0.000000 0.000000 ( 0.008845)
10 times 0.040000 0.000000 0.040000 ( 0.072312)
100 times 0.560000 0.020000 0.580000 ( 0.666038)
Search by [jack]
------------------------------------------------------------------------------------------
["Jackal Odoriferously", "Jack Preopening", "Jackanapish Earlship", "Jackanapish Pectolite", "Jackanapes Iodization", "Jackal Intermixedly", "Jackanapes Contrawise", "Jack Cionorrhaphia", "Jack Handkerchiefful", "Jack Voltaelectrometric"]
------------------------------------------------------------------------------------------
There have [100] items like 'jack'
user system total real
1 times 0.000000 0.000000 0.000000 ( 0.002702)
10 times 0.040000 0.000000 0.040000 ( 0.057028)
100 times 0.420000 0.010000 0.430000 ( 0.544384)
Benchmark.bm do|bm|
puts " c result:\n#{Redis::Search.complete("CategoryTest","c", :limit => 10).collect { |c| c['title'] }}"
bm.report(" 'c' word 10 times") do
10.times do |i|
Redis::Search.complete("CategoryTest","c", :limit => 10)
end
end
puts " a result:\n#{Redis::Search.complete("CategoryTest","a", :limit => 10).collect { |c| c['title'] }}"
bm.report(" 'a' word 10 times") do
10.times do |i|
Redis::Search.complete("CategoryTest","a", :limit => 10)
end
end
puts " b result:\n#{Redis::Search.complete("CategoryTest","b", :limit => 10).collect { |c| c['title'] }}"
bm.report(" 'b' word 10 times") do
10.times do |i|
Redis::Search.complete("CategoryTest","b", :limit => 10)
end
end
puts " f result:\n#{Redis::Search.complete("CategoryTest","f", :limit => 10).collect { |c| c['title'] }}"
bm.report(" 'f' word 10 times") do
10.times do |i|
Redis::Search.complete("CategoryTest","f", :limit => 10)
end
end
puts " t result:\n#{Redis::Search.complete("CategoryTest","t", :limit => 10).collect { |c| c['title'] }}"
bm.report(" 't' word 10 times") do
10.times do |i|
Redis::Search.complete("CategoryTest","t", :limit => 10)
end
end
puts " d result:\n#{Redis::Search.complete("CategoryTest","d", :limit => 10).collect { |c| c['title'] }}"
bm.report(" 'd' word 10 times") do
10.times do |i|
Redis::Search.complete("CategoryTest","d", :limit => 10)
end
end
puts " m result:\n#{Redis::Search.complete("CategoryTest","m", :limit => 10).collect { |c| c['title'] }}"
bm.report(" 'm' word 10 times") do
10.times do |i|
Redis::Search.complete("CategoryTest","m", :limit => 10)
end
end
end
user system total real
c result:
["Caam Atimon", "C Precanonical", "Caama Laicizer", "Ca Squatarole", "Caam Fallowist", "Caama Rejail", "Caama Delegant", "C Sphenophyllales", "C Quadrifoliolate", "Caama Endolymph"]
'c' word 10 times 0.080000 0.000000 0.080000 ( 0.095804)
a result:
["Aa Knavish", "A Unbehaving", "A Dilettantish", "Aa Galactodendron", "A Attorney", "Aa Cryptolunatic", "Aalii Akindle", "A Mealywing", "Aal Studerite", "Aal Viosterol"]
'a' word 10 times 0.130000 0.000000 0.130000 ( 0.151075)
b result:
["Baa Zadruga", "Baa Jager", "Ba Boronatrocalcite", "B Platinammine", "B Welly", "B Hoplocephalus", "B Gymnospermal", "B Unquote", "B Planktologist", "B Thermotical"]
'b' word 10 times 0.070000 0.010000 0.080000 ( 0.090507)
f result:
["Fabaceous Santalic", "F Iconodulist", "Fa Stomatodaeal", "Fa Bel", "F Annotative", "Fabaceous Strawsmear", "Fabella Jewbush", "F Trichinopoly", "Fabaceae Logical", "Faba Delphinine"]
'f' word 10 times 0.070000 0.000000 0.070000 ( 0.092728)
t result:
["T Dramaticism", "T Pleomastia", "T Broomstick", "T Guglia", "T Rectifiable", "T Monostichous", "T Amole", "T Dressage", "T Straka", "T Sclater"]
't' word 10 times 0.080000 0.000000 0.080000 ( 0.085717)
d result:
["D Blockheadish", "Dab Disasinate", "Dab Quaverous", "Dab Nervulose", "Dab Carbolineum", "Da Icacinaceous", "Da Assess", "D Prayingwise", "D Expatriation", "Daalder Switchback"]
'd' word 10 times 0.070000 0.000000 0.070000 ( 0.083891)
m result:
["M Shapometer", "Ma Granulitis", "Maamselle Dismembered", "Ma Loyalism", "Ma Terfeziaceae", "Maamselle Heptatrema", "M Overfast", "Ma Acquiesce", "M Oncia", "M Petticoaty"]
'm' word 10 times 0.070000 0.010000 0.080000 ( 0.082869)
redis-search 0.7
Result: