Skip to content

Commit

Permalink
Add fluentd benchmark (#243)
Browse files Browse the repository at this point in the history
* Add fluentd benchmark

* Add more variants to error messages
  • Loading branch information
k0kubun authored Jul 27, 2023
1 parent d2d20c4 commit 4cc2446
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
2 changes: 2 additions & 0 deletions benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ etanni:
desc: etanni is an older, extremely simple template-lang format that basically turns your template into an "eval" with a lot of heredocs.
fannkuchredux:
desc: fannkuchredux from the Computer Language Benchmarks Game.
fluentd:
desc: fluentd is a log collector, which parses logs in a server and forwards them to various destinations.
ruby-json:
desc: an optimized version of the json_pure gem's pure Ruby JSON parser.
lee:
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/fluentd/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

gem 'fluentd'
gem 'cool.io', github: 'k0kubun/cool.io', branch: 'ruby-3-3'
46 changes: 46 additions & 0 deletions benchmarks/fluentd/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
GIT
remote: https://github.com/k0kubun/cool.io.git
revision: 61e3caf8b961fb1a4d46b367eb58ebcddb45da4a
branch: ruby-3-3
specs:
cool.io (1.7.1)

GEM
remote: https://rubygems.org/
specs:
concurrent-ruby (1.2.2)
fluentd (1.16.2)
bundler
cool.io (>= 1.4.5, < 2.0.0)
http_parser.rb (>= 0.5.1, < 0.9.0)
msgpack (>= 1.3.1, < 2.0.0)
serverengine (>= 2.3.2, < 3.0.0)
sigdump (~> 0.2.5)
strptime (>= 0.2.4, < 1.0.0)
tzinfo (>= 1.0, < 3.0)
tzinfo-data (~> 1.0)
webrick (~> 1.4)
yajl-ruby (~> 1.0)
http_parser.rb (0.8.0)
msgpack (1.7.2)
serverengine (2.3.2)
sigdump (~> 0.2.2)
sigdump (0.2.5)
strptime (0.2.5)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
tzinfo-data (1.2023.3)
tzinfo (>= 1.0.0)
webrick (1.8.1)
yajl-ruby (1.4.3)

PLATFORMS
arm64-darwin-22
x86_64-linux

DEPENDENCIES
cool.io!
fluentd

BUNDLED WITH
2.4.1
30 changes: 30 additions & 0 deletions benchmarks/fluentd/benchmark.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

require 'harness'

Dir.chdir(__dir__)
use_gemfile

require 'fluent/engine'
require 'fluent/parser'

# Prepare a fixture
time = Time.new(2023, 7, 27, 9, 00, 00)
errors = [
"Skipping user-data validation. No user-data found.",
"Python version change detected. Purging cache",
"No instance datasource found.",
"No kernel command line url found.",
"No local datasource found",
]
ltsv = 1000.times.map { |i| "time:#{time + i} module:main.py level:DEBUG message:#{errors.sample}\n" }.join
ltsv *= 1000

# Prepare an LTSV parser
parser = Fluent::Plugin::LabeledTSVParser.new
parser.configure(Fluent::Config::Element.new('parse', '', {}, []))

# Benchmark the `<parse>@type ltsv</parse>` use case
run_benchmark(10) do
parser.parse(ltsv) {}
end

0 comments on commit 4cc2446

Please sign in to comment.