Sha256: 40c2646482c5198e095be784da427b1880f290c5544b4621bb8923fcd45e731e

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

require_relative 'helper'
require 'fluent/plugin/filter_ua_parser'

# setup
Fluent::Test.setup
config = %[
  @type ua_parser
  key_name user_agent
  delete_key no
  flatten
  out_key ua
]

tag = 'foo.bar'
driver = Fluent::Test::Driver::Filter.new(Fluent::Plugin::UaParserFilter).configure(config)

# bench
require 'benchmark'
require 'csv'
n = 100000

ua_list = CSV.read('bench_ua_list.csv')
ua_list_len = ua_list.length

Benchmark.bm(7) do |x|
  x.report { driver.run(default_tag: tag) { n.times { driver.feed({'user_agent' => ua_list[rand(ua_list_len)][0]}) } } }
end


# Without LRU cache
#              user     system      total        real
#        151.570000   0.780000 152.350000 (153.154123)
# With LRU cache(512)  & random 512 UA
#              user     system      total        real
#          3.720000   0.100000   3.820000 (  3.825439)
# With LRU cache(4096) & random 512 UA   <- using
#              user     system      total        real
#          3.830000   0.100000   3.930000 (  3.940422)

# fluent-plugin-woothee
# (https://github.com/woothee/fluent-plugin-woothee)
#              user     system      total        real
#          3.770000   0.050000   3.820000 (  3.850436)

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
fluent-plugin-user-agent-parser-1.2.0 test/bench_filter_ua_parser.rb
fluent-plugin-ua-parser-1.2.0 test/bench_filter_ua_parser.rb