public
Last active

redis-search 0.3 Benchmark, 用户昵称搜索(10个字以内)

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
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 次搜索请求

50W 数据

Search 的 all count:14779...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.069510)
Search 10 0.000000 0.000000 0.000000 ( 0.132639)
Search 100 0.050000 0.010000 0.060000 ( 0.749259)
Search 1000 0.570000 0.110000 0.680000 ( 7.428578)
Search 10000 5.350000 0.830000 6.180000 ( 70.405171)

Search 美丽 all count:1418...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.004140)
Search 10 0.070000 0.010000 0.080000 ( 0.128747)
Search 100 0.040000 0.010000 0.050000 ( 0.279415)
Search 1000 0.570000 0.130000 0.700000 ( 3.032143)
Search 10000 5.630000 1.300000 6.930000 ( 29.999101)

Search 云 all count:2524...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.020900)
Search 10 0.010000 0.000000 0.010000 ( 0.010576)
Search 100 0.030000 0.010000 0.040000 ( 0.113347)
Search 1000 0.500000 0.060000 0.560000 ( 1.479681)
Search 10000 4.890000 0.680000 5.570000 ( 14.476430)

Search 云儿 all count:43...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.001181)
Search 10 0.010000 0.000000 0.010000 ( 0.012382)
Search 100 0.040000 0.010000 0.050000 ( 0.134838)
Search 1000 0.570000 0.120000 0.690000 ( 1.449223)
Search 10000 5.670000 1.250000 6.920000 ( 13.740069)

Search 花 all count:4394...
user system total real
Search 1 0.010000 0.000000 0.010000 ( 0.002426)
Search 10 0.000000 0.000000 0.000000 ( 0.015570)
Search 100 0.040000 0.010000 0.050000 ( 0.200147)
Search 1000 0.510000 0.070000 0.580000 ( 2.100327)
Search 10000 5.030000 0.690000 5.720000 ( 20.620810)

Search 云儿的 all count:3...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.000902)
Search 10 0.010000 0.000000 0.010000 ( 0.008606)
Search 100 0.020000 0.010000 0.030000 ( 0.093690)
Search 1000 0.270000 0.130000 0.400000 ( 1.177355)
Search 10000 2.380000 1.180000 3.560000 ( 9.545034)

100W 数据

Search 的 all count:30812...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.197708)
Search 10 0.130000 0.030000 0.160000 ( 0.613590)
Search 100 0.050000 0.010000 0.060000 ( 2.975337)
Search 1000 0.540000 0.110000 0.650000 ( 30.046868)
Search 10000 6.010000 1.090000 7.100000 (315.901688)

Search 美丽 all count:3189...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.051153)
Search 10 0.010000 0.000000 0.010000 ( 0.054661)
Search 100 0.050000 0.010000 0.060000 ( 0.791882)
Search 1000 0.630000 0.150000 0.780000 ( 8.154113)
Search 10000 6.240000 1.490000 7.730000 ( 81.955262)

Search 云 all count:4991...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.064281)
Search 10 0.000000 0.000000 0.000000 ( 0.017935)
Search 100 0.040000 0.010000 0.050000 ( 0.259907)
Search 1000 0.510000 0.070000 0.580000 ( 3.069304)
Search 10000 4.950000 0.740000 5.690000 ( 29.571512)

Search 云儿 all count:105...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.004971)
Search 10 0.000000 0.000000 0.000000 ( 0.019429)
Search 100 0.120000 0.020000 0.140000 ( 0.302361)
Search 1000 0.530000 0.140000 0.670000 ( 2.531547)
Search 10000 5.760000 1.340000 7.100000 ( 19.661423)

Search 花 all count:9172...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.084360)
Search 10 0.000000 0.000000 0.000000 ( 0.030188)
Search 100 0.040000 0.010000 0.050000 ( 0.469149)
Search 1000 0.560000 0.080000 0.640000 ( 5.501214)
Search 10000 5.190000 0.760000 5.950000 ( 52.260485)

Search 云儿的 all count:7...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.006335)
Search 10 0.000000 0.010000 0.010000 ( 0.077048)
Search 100 0.030000 0.010000 0.040000 ( 0.152033)
Search 1000 0.340000 0.120000 0.460000 ( 1.640716)
Search 10000 3.300000 1.260000 4.560000 ( 16.441062)

150W 数据

Search 的 all count:47740...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.278129)
Search 10 0.000000 0.000000 0.000000 ( 0.482222)
Search 100 0.240000 0.060000 0.300000 ( 7.064037)
Search 1000 0.580000 0.130000 0.710000 ( 65.314955)

Search 美丽 all count:4691...
user system total real
Search 1 0.000000 0.010000 0.010000 ( 0.078372)
Search 10 0.010000 0.000000 0.010000 ( 0.015946)
Search 100 0.040000 0.000000 0.040000 ( 0.243507)
Search 1000 0.540000 0.110000 0.650000 ( 2.920669)

Search 云 all count:7568...
user system total real
Search 1 0.010000 0.000000 0.010000 ( 0.090763)
Search 10 0.000000 0.000000 0.000000 ( 0.115175)
Search 100 0.030000 0.010000 0.040000 ( 0.425991)
Search 1000 0.530000 0.080000 0.610000 ( 4.560025)

Search 云儿 all count:155...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.000755)
Search 10 0.000000 0.000000 0.000000 ( 0.006693)
Search 100 0.040000 0.010000 0.050000 ( 0.069568)
Search 1000 0.460000 0.100000 0.560000 ( 0.773605)

Search 花 all count:14351...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.142486)
Search 10 0.000000 0.010000 0.010000 ( 0.172451)
Search 100 0.050000 0.000000 0.050000 ( 1.022724)
Search 1000 0.560000 0.090000 0.650000 ( 10.410757)

Search 云儿的 all count:11...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.000577)
Search 10 0.010000 0.000000 0.010000 ( 0.005051)
Search 100 0.020000 0.010000 0.030000 ( 0.061536)
Search 1000 0.350000 0.090000 0.440000 ( 0.588164)

前缀匹配依次搜索测试

# coding: utf-8
require "benchmark"

["a","ab","b","bi","bit"].each do |key|
  count = RedisSearch::Search.query("User", key, :limit => 1000000).count
  puts "="*80
  puts "Complete search #{key} all count:#{count}..."
  Benchmark.bm do |bm|
    [1, 10, 100, 1000].each do |i|
      bm.report("Search #{i}") do
        i.times do |n|
          RedisSearch::Search.complete("User", key, :limit => 20)
        end
      end
    end
  end
end

Complete search a all count:850...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.002755)
Search 10 0.030000 0.000000 0.030000 ( 0.025136)
Search 100 0.260000 0.020000 0.280000 ( 0.323718)
Search 1000 2.430000 0.160000 2.590000 ( 2.934027)

Complete search ab all count:16...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.002899)
Search 10 0.050000 0.000000 0.050000 ( 0.057681)
Search 100 0.240000 0.020000 0.260000 ( 0.291592)
Search 1000 2.480000 0.160000 2.640000 ( 2.990286)

Complete search b all count:239...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.004034)
Search 10 0.020000 0.000000 0.020000 ( 0.026697)
Search 100 0.260000 0.020000 0.280000 ( 0.311989)
Search 1000 2.420000 0.160000 2.580000 ( 2.906780)

Complete search bi all count:7...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.002794)
Search 10 0.020000 0.000000 0.020000 ( 0.025504)
Search 100 0.260000 0.020000 0.280000 ( 0.310722)
Search 1000 2.460000 0.160000 2.620000 ( 2.994616)

Complete search bit all count:4...
user system total real
Search 1 0.000000 0.000000 0.000000 ( 0.002274)
Search 10 0.050000 0.000000 0.050000 ( 0.048868)
Search 100 0.190000 0.020000 0.210000 ( 0.242438)
Search 1000 1.960000 0.170000 2.130000 ( 2.550504)

redis-search 0.7

random = RandomWord.new
Benchmark.bm do|bm|
  bm.report("Index 100,000 categories data ") do
    100_000.times do |i|
      Redis::Search::Index.new(:type => "CategoryTest",
                              :title => random.next, 
                              :id => i,
                              :prefix_index_enable => true,
                              :score => i).save
    end
  end
end

Result:

               user            system      total            real
Index 100,000 categories data 201.880000  66.550000 268.430000 (505.133822)

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)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.