integration perf test

This commit is contained in:
Peter Bhat Harkins 2023-08-09 10:51:54 -05:00
parent ea9bd69b26
commit ef571dfd31
4 changed files with 30 additions and 8 deletions

View File

@ -49,6 +49,7 @@ gem 'transaction_retry' # mitigate https://github.com/lobsters/lobsters-ansible/
gem 'rack-attack' # rate-limiting
group :test, :development do
gem 'benchmark-perf'
gem 'capybara'
gem 'database_cleaner'
gem "listen"

View File

@ -76,6 +76,7 @@ GEM
afm (0.2.2)
ast (2.4.2)
bcrypt (3.1.18)
benchmark-perf (0.6.0)
builder (3.2.4)
byebug (11.1.3)
capybara (3.39.0)
@ -324,6 +325,7 @@ DEPENDENCIES
actionpack-page_caching
activerecord-typedstore
bcrypt (~> 3.1.2)
benchmark-perf
byebug
capybara
commonmarker (>= 0.23.6)

View File

@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# to use:
# change force_ssl to false in config/environments/production.rb
# SECRET_KEY_BASE=asdf rails server -e production -p 3000
# be ruby script/comment_tree_perf.rb > [implementation].csv
#
# assumes a local server is running in prod mode with prod data
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require APP_PATH
Rails.application.require_environment!
require 'benchmark-perf'
puts "short_id,comments_count,avg,stdev,dt"
Story.where('comments_count > 0').find_each(batch_size: 100) do |story|
# no warmup because the db difference on fetches is ~50%
# and we render old stories not in cache all day
result = Benchmark::Perf.cpu(warmup: 0, repeat: 10) do
`curl -qs http://localhost:3000/s/#{story.short_id} -o /dev/null`
end
puts "#{story.short_id},#{story.comments_count},#{result.avg},#{result.stdev},#{result.dt}"
end

View File

@ -11,14 +11,6 @@ end
# max_depth_seen = 0
# integration perf test: loop all stories and time rendering them 10x
# run w arrange_for_user
# run w selected
# run w selected_bytepack
# better name for ord/ordpath
# extract exploratory tests in test_bitpacking to test suite
# future: replace confidence w ord
Story.find_each(batch_size: 100) do |story|
selected_comments = ActiveRecord::Base.connection.exec_query <<~SQL
with recursive discussion as (