Skip to content

Commit

Permalink
include benchmarks. #224
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Apr 8, 2019
1 parent b84c030 commit b507ef2
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 127 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ gem 'git', '~> 1.5'

group :development, :test do
gem 'rspec-rails', '~> 3.5', '>= 3.5.2'
gem 'rspec-benchmark', '~> 0.4.0'
gem "better_errors"
gem "binding_of_caller"
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
Expand Down
148 changes: 80 additions & 68 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ GEM
specs:
aasm (5.0.2)
concurrent-ruby (~> 1.0)
actioncable (5.2.2)
actionpack (= 5.2.2)
actioncable (5.2.3)
actionpack (= 5.2.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.2)
actionpack (= 5.2.2)
actionview (= 5.2.2)
activejob (= 5.2.2)
actionmailer (5.2.3)
actionpack (= 5.2.3)
actionview (= 5.2.3)
activejob (= 5.2.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.2)
actionview (= 5.2.2)
activesupport (= 5.2.2)
actionpack (5.2.3)
actionview (= 5.2.3)
activesupport (= 5.2.3)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.2)
activesupport (= 5.2.2)
actionview (5.2.3)
activesupport (= 5.2.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
Expand All @@ -31,51 +31,54 @@ GEM
activemodel (>= 4.1, < 6)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (5.2.2)
activesupport (= 5.2.2)
activejob (5.2.3)
activesupport (= 5.2.3)
globalid (>= 0.3.6)
activemodel (5.2.2)
activesupport (= 5.2.2)
activerecord (5.2.2)
activemodel (= 5.2.2)
activesupport (= 5.2.2)
activemodel (5.2.3)
activesupport (= 5.2.3)
activerecord (5.2.3)
activemodel (= 5.2.3)
activesupport (= 5.2.3)
arel (>= 9.0)
activestorage (5.2.2)
actionpack (= 5.2.2)
activerecord (= 5.2.2)
activestorage (5.2.3)
actionpack (= 5.2.3)
activerecord (= 5.2.3)
marcel (~> 0.3.1)
activesupport (5.2.2)
activesupport (5.2.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.5.2)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
ansi (1.5.0)
api-pagination (4.8.2)
arel (9.0.0)
audited (4.8.0)
activerecord (>= 4.0, < 5.3)
aws-eventstream (1.0.2)
aws-partitions (1.144.0)
aws-sdk-core (3.46.2)
aws-eventstream (~> 1.0)
aws-partitions (1.149.0)
aws-sdk-core (3.48.3)
aws-eventstream (~> 1.0, >= 1.0.2)
aws-partitions (~> 1.0)
aws-sigv4 (~> 1.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-kms (1.13.0)
aws-sdk-core (~> 3, >= 3.39.0)
aws-sigv4 (~> 1.0)
aws-sdk-s3 (1.31.0)
aws-sdk-core (~> 3, >= 3.39.0)
aws-sdk-kms (1.16.0)
aws-sdk-core (~> 3, >= 3.48.2)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.36.0)
aws-sdk-core (~> 3, >= 3.48.2)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.0)
aws-sdk-sqs (1.10.0)
aws-sdk-core (~> 3, >= 3.39.0)
aws-sigv4 (~> 1.0)
aws-sigv4 (1.0.3)
aws-sdk-sqs (1.13.0)
aws-sdk-core (~> 3, >= 3.48.2)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.1.0)
aws-eventstream (~> 1.0, >= 1.0.2)
base32-url (0.5)
bcrypt (3.1.12)
benchmark-perf (0.4.0)
benchmark-trend (0.2.0)
benchmark_methods (0.7)
bergamasco (0.3.17)
activesupport (>= 4.2.5, < 6)
Expand Down Expand Up @@ -118,12 +121,12 @@ GEM
rdf-rdfxml (~> 2.0)
rdf-turtle (~> 2.2)
thor (~> 0.19)
bootsnap (1.4.1)
bootsnap (1.4.2)
msgpack (~> 1.0)
builder (3.2.3)
byebug (11.0.0)
byebug (11.0.1)
cancancan (2.3.0)
capybara (3.14.0)
capybara (3.16.1)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
Expand Down Expand Up @@ -162,7 +165,7 @@ GEM
csl (~> 1.0)
css_parser (1.7.0)
addressable
dalli (2.7.9)
dalli (2.7.10)
database_cleaner (1.7.0)
debug_inspector (0.0.3)
diff-lcs (1.3)
Expand All @@ -171,16 +174,16 @@ GEM
docopt (0.6.1)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.7.1)
dotenv (2.7.2)
ebnf (1.1.3)
rdf (~> 3.0)
sxp (~> 1.0)
edtf (3.0.4)
activesupport (>= 3.0, < 6.0)
elasticsearch (6.1.0)
elasticsearch-api (= 6.1.0)
elasticsearch-transport (= 6.1.0)
elasticsearch-api (6.1.0)
elasticsearch (6.3.0)
elasticsearch-api (= 6.3.0)
elasticsearch-transport (= 6.3.0)
elasticsearch-api (6.3.0)
multi_json
elasticsearch-extensions (0.0.31)
ansi
Expand All @@ -190,7 +193,7 @@ GEM
elasticsearch (> 1)
hashie
elasticsearch-rails (6.0.0)
elasticsearch-transport (6.1.0)
elasticsearch-transport (6.3.0)
faraday
multi_json
equivalent-xml (0.6.0)
Expand Down Expand Up @@ -299,15 +302,15 @@ GEM
method_source (0.9.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mime-types-data (3.2019.0331)
mimemagic (0.3.3)
mini_magick (4.9.3)
mini_mime (1.0.1)
mini_portile2 (2.3.0)
minitest (5.11.3)
money (6.13.2)
i18n (>= 0.6.4, <= 2)
msgpack (1.2.8)
msgpack (1.2.9)
multi_json (1.13.1)
multipart-post (2.0.0)
mysql2 (0.4.10)
Expand All @@ -319,9 +322,9 @@ GEM
oj (2.18.5)
oj_mimic_json (1.0.1)
pandoc-ruby (2.0.2)
postrank-uri (1.0.23)
addressable (>= 2.3.0, < 2.6)
nokogiri (>= 1.6.1, < 1.9)
postrank-uri (1.0.24)
addressable (>= 2.4.0)
nokogiri (>= 1.8.0)
public_suffix (>= 2.0.0, < 2.1)
premailer (1.11.1)
addressable
Expand All @@ -331,35 +334,35 @@ GEM
pwqgen.rb (0.1.0)
docopt (~> 0.5)
sysrandom
rack (2.0.6)
rack (2.0.7)
rack-accept (0.4.5)
rack (>= 0.4)
rack-cors (1.0.2)
rack-cors (1.0.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rack-utf8_sanitizer (1.6.0)
rack (>= 1.0, < 3.0)
rails (5.2.2)
actioncable (= 5.2.2)
actionmailer (= 5.2.2)
actionpack (= 5.2.2)
actionview (= 5.2.2)
activejob (= 5.2.2)
activemodel (= 5.2.2)
activerecord (= 5.2.2)
activestorage (= 5.2.2)
activesupport (= 5.2.2)
rails (5.2.3)
actioncable (= 5.2.3)
actionmailer (= 5.2.3)
actionpack (= 5.2.3)
actionview (= 5.2.3)
activejob (= 5.2.3)
activemodel (= 5.2.3)
activerecord (= 5.2.3)
activestorage (= 5.2.3)
activesupport (= 5.2.3)
bundler (>= 1.3.0)
railties (= 5.2.2)
railties (= 5.2.3)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.2.2)
actionpack (= 5.2.2)
activesupport (= 5.2.2)
railties (5.2.3)
actionpack (= 5.2.3)
activesupport (= 5.2.3)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
Expand Down Expand Up @@ -388,13 +391,21 @@ GEM
rdf (>= 2.2, < 4.0)
rdf-xsd (3.0.1)
rdf (~> 3.0)
regexp_parser (1.3.0)
regexp_parser (1.4.0)
request_store (1.4.1)
rack (>= 1.4)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-benchmark (0.4.0)
benchmark-perf (~> 0.4.0)
benchmark-trend (~> 0.2.0)
rspec (>= 3.0.0, < 4.0.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
Expand Down Expand Up @@ -544,6 +555,7 @@ DEPENDENCIES
rack-utf8_sanitizer (~> 1.6)
rails (~> 5.2.0)
rake (~> 12.0)
rspec-benchmark (~> 0.4.0)
rspec-rails (~> 3.5, >= 3.5.2)
sentry-raven (~> 2.9)
shoryuken (~> 4.0)
Expand Down
17 changes: 13 additions & 4 deletions app/controllers/clients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,22 @@ def destroy
end

def totals
logger = Logger.new(STDOUT)

page = { size: 0, number: 1}
response = Doi.query(nil, provider_id: params[:provider_id], page: page, totals_agg: true)
response = nil
logger.info "[Benchmark] clients totals " + Benchmark.ms {
response = Doi.query(nil, provider_id: params[:provider_id], page: page, totals_agg: true)
}.to_s + " ms"
total = response.results.total

registrant = total > 0 ? clients_totals(response.response.aggregations.clients_totals.buckets) : nil

render json: registrant, status: :ok
registrant = nil
logger.info "[Benchmark] clients clients_totals " + Benchmark.ms {
registrant = total > 0 ? clients_totals(response.response.aggregations.clients_totals.buckets) : nil
}.to_s + " ms"
logger.info "[Benchmark] clients render " + Benchmark.ms {
render json: registrant, status: :ok
}.to_s + " ms"
end

protected
Expand Down
1 change: 0 additions & 1 deletion app/controllers/concerns/facetable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ def clients_totals(arr)

ids = arr.map { |hsh| hsh["key"] }.join(",")
clients = Client.find_by_ids(ids, size: 2000).results.reduce({}) do |sum, p|
puts sum
sum[p.symbol.downcase] = p.name
sum
end
Expand Down
Loading

0 comments on commit b507ef2

Please sign in to comment.