Skip to content

Commit

Permalink
Fix rubocop error
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Nov 11, 2023
1 parent 60bde1c commit f64d3c3
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Metrics/MethodLength:
Minitest/MultipleAssertions:
Enabled: false

Style/BlockComments:
Enabled: false

Style/ClassVars:
Enabled: false

Expand Down
33 changes: 30 additions & 3 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,52 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-11-03 17:03:03 UTC using RuboCop version 1.57.2.
# on 2023-11-11 06:48:00 UTC using RuboCop version 1.57.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 3
# Offense count: 4
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
Exclude:
- 'example/benchmark_insert.rb'
- 'example/benchmark_select.rb'

# Offense count: 8
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
Naming/MethodParameterName:
Exclude:
- 'example/benchmark_insert.rb'
- 'example/benchmark_select.rb'

# Offense count: 2
# Configuration parameters: AllowedChars.
# AllowedChars: ©
Style/AsciiComments:
Exclude:
- 'example/benchmark_insert.rb'
- 'example/benchmark_select.rb'

# Offense count: 7
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'example/benchmark_insert.rb'
- 'example/benchmark_select.rb'
- 'ext/ilios/extconf.rb'
- 'lib/ilios.rb'

# Offense count: 4
# Offense count: 16
# Configuration parameters: RequireForNonPublicMethods.
Style/DocumentationMethod:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'example/benchmark_insert.rb'
- 'example/benchmark_select.rb'
- 'ext/ilios/extconf.rb'
- 'lib/ilios.rb'
62 changes: 36 additions & 26 deletions example/benchmark_insert.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
Expand All @@ -7,10 +9,9 @@
gem 'ilios'
end


Ilios::Cassandra.config = {
keyspace: 'ilios',
hosts: ['127.0.0.1'],
hosts: ['127.0.0.1']
}

# Create new table
Expand All @@ -30,7 +31,6 @@
CQL
Ilios::Cassandra.session.execute(statement)


class BenchmarkCassandra
def initialize
@cluster = Cassandra.cluster
Expand All @@ -40,25 +40,31 @@ def initialize

def run_execute(x)
x.report('cassandra-driver:execute') do
@session.execute(statement, {
arguments: {
id: Random.rand(2**40),
message: 'hello',
created_at: Time.now
@session.execute(
statement,
{
arguments: {
id: Random.rand(2**40),
message: 'hello',
created_at: Time.now
}
}
})
)
end
end

def run_execute_async(x)
x.report('cassandra-driver:execute_async') do
future = @session.execute_async(statement, {
arguments: {
id: Random.rand(2**40),
message: 'hello',
created_at: Time.now
future = @session.execute_async(
statement,
{
arguments: {
id: Random.rand(2**40),
message: 'hello',
created_at: Time.now
}
}
})
)
future.on_success do |rows|
end
end
Expand All @@ -78,22 +84,26 @@ def statement
class BenchmarkIlios
def run_execute(x)
x.report('ilios:execute') do
statement.bind({
id: Random.rand(2**40),
message: 'hello',
created_at: Time.now
})
statement.bind(
{
id: Random.rand(2**40),
message: 'hello',
created_at: Time.now
}
)
Ilios::Cassandra.session.execute(statement)
end
end

def run_execute_async(x)
x.report('ilios:execute_async') do
statement.bind({
id: Random.rand(2**40),
message: 'hello',
created_at: Time.now
})
statement.bind(
{
id: Random.rand(2**40),
message: 'hello',
created_at: Time.now
}
)
future = Ilios::Cassandra.session.execute_async(statement)
future.on_success do |results|
results.each do |row|
Expand All @@ -120,7 +130,7 @@ def statement

sleep 10

puts ""
puts ''
Benchmark.ips do |x|
BenchmarkIlios.new.run_execute(x)
BenchmarkIlios.new.run_execute_async(x)
Expand Down
20 changes: 11 additions & 9 deletions example/benchmark_select.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
Expand All @@ -7,10 +9,9 @@
gem 'ilios'
end


Ilios::Cassandra.config = {
keyspace: 'ilios',
hosts: ['127.0.0.1'],
hosts: ['127.0.0.1']
}

# Create new table
Expand Down Expand Up @@ -40,15 +41,16 @@
CQL

1000.times do
statement.bind({
id: Random.rand(2**40),
message: 'hello',
created_at: Time.now
})
statement.bind(
{
id: Random.rand(2**40),
message: 'hello',
created_at: Time.now
}
)
Ilios::Cassandra.session.execute(statement)
end


class BenchmarkCassandra
def initialize
@cluster = Cassandra.cluster
Expand Down Expand Up @@ -108,7 +110,7 @@ def statement

sleep 10

puts ""
puts ''
Benchmark.ips do |x|
BenchmarkIlios.new.run_execute(x)
BenchmarkIlios.new.run_execute_async(x)
Expand Down

0 comments on commit f64d3c3

Please sign in to comment.