Rename dummy to benchmark

This commit is contained in:
Benjamin Fleischer 2016-03-09 21:55:33 -06:00
parent 821dcda700
commit 666756f779
8 changed files with 19 additions and 19 deletions

View File

@ -15,7 +15,7 @@ require 'English'
class BenchmarkDriver class BenchmarkDriver
ROOT = Pathname File.expand_path(File.join('..', '..'), __FILE__) ROOT = Pathname File.expand_path(File.join('..', '..'), __FILE__)
BASE = ENV.fetch('BASE') { ROOT.join('test', 'dummy') } BASE = ENV.fetch('BASE') { ROOT.join('test', 'benchmark') }
ESCAPED_BASE = Shellwords.shellescape(BASE) ESCAPED_BASE = Shellwords.shellescape(BASE)
def self.benchmark(options) def self.benchmark(options)

View File

@ -4,18 +4,18 @@ set -e
case "$1" in case "$1" in
start) start)
config="${CONFIG_RU:-test/dummy/config.ru}" config="${CONFIG_RU:-test/benchmark/config.ru}"
bundle exec ruby -Ilib -S rackup "$config" --daemonize --pid tmp/dummy_app.pid --warn --server webrick bundle exec ruby -Ilib -S rackup "$config" --daemonize --pid tmp/benchmark_app.pid --warn --server webrick
until [ -f 'tmp/dummy_app.pid' ]; do until [ -f 'tmp/benchmark_app.pid' ]; do
sleep 0.1 # give it time to start.. I don't know a better way sleep 0.1 # give it time to start.. I don't know a better way
done done
cat tmp/dummy_app.pid cat tmp/benchmark_app.pid
true true
;; ;;
stop) stop)
if [ -f 'tmp/dummy_app.pid' ]; then if [ -f 'tmp/benchmark_app.pid' ]; then
kill -TERM $(cat tmp/dummy_app.pid) kill -TERM $(cat tmp/benchmark_app.pid)
else else
echo 'No pidfile' echo 'No pidfile'
false false
@ -23,8 +23,8 @@ case "$1" in
;; ;;
status) status)
if [ -f 'tmp/dummy_app.pid' ]; then if [ -f 'tmp/benchmark_app.pid' ]; then
kill -0 $(cat tmp/dummy_app.pid) kill -0 $(cat tmp/benchmark_app.pid)
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
else else
echo 'No pidfile' echo 'No pidfile'

View File

@ -18,7 +18,7 @@ class NullLogger < Logger
def add(*_args, &_block) def add(*_args, &_block)
end end
end end
class DummyLogger < ActiveSupport::Logger class BenchmarkLogger < ActiveSupport::Logger
def initialize def initialize
@file = StringIO.new @file = StringIO.new
super(@file) super(@file)
@ -30,7 +30,7 @@ class DummyLogger < ActiveSupport::Logger
end end
end end
# ref: https://gist.github.com/bf4/8744473 # ref: https://gist.github.com/bf4/8744473
class DummyApp < Rails::Application class BenchmarkApp < Rails::Application
# Set up production configuration # Set up production configuration
config.eager_load = true config.eager_load = true
config.cache_classes = true config.cache_classes = true

View File

@ -7,7 +7,7 @@ module Benchmark
module ActiveModelSerializers module ActiveModelSerializers
module TestMethods module TestMethods
def request(method, path) def request(method, path)
response = Rack::MockRequest.new(DummyApp).send(method, path) response = Rack::MockRequest.new(BenchmarkApp).send(method, path)
if response.status.in?([404, 500]) if response.status.in?([404, 500])
fail "omg, #{method}, #{path}, '#{response.status}', '#{response.body}'" fail "omg, #{method}, #{path}, '#{response.status}', '#{response.body}'"
end end

View File

@ -35,7 +35,7 @@ class PostController < ActionController::Base
ActionController::Base.cache_store.clear ActionController::Base.cache_store.clear
# Test caching is on # Test caching is on
# Uncomment to turn on logger; possible performance issue # Uncomment to turn on logger; possible performance issue
# logger = DummyLogger.new # logger = BenchmarkLogger.new
# ActiveSupport::Cache::Store.logger = logger # seems to be the best way # ActiveSupport::Cache::Store.logger = logger # seems to be the best way
# #
# the below is used in some rails tests but isn't available/working in all versions, so far as I can tell # the below is used in some rails tests but isn't available/working in all versions, so far as I can tell
@ -57,7 +57,7 @@ class PostController < ActionController::Base
end end
def cache_messages def cache_messages
ActiveSupport::Cache::Store.logger.is_a?(DummyLogger) && ActiveSupport::Cache::Store.logger.messages.split("\n") ActiveSupport::Cache::Store.logger.is_a?(BenchmarkLogger) && ActiveSupport::Cache::Store.logger.messages.split("\n")
end end
def toggle_cache_status def toggle_cache_status

View File

@ -104,7 +104,7 @@ else
# ActiveModelSerializers::Model is a convenient # ActiveModelSerializers::Model is a convenient
# serializable class to inherit from when making # serializable class to inherit from when making
# serializable non-activerecord objects. # serializable non-activerecord objects.
class DummyModel class BenchmarkModel
include ActiveModel::Model include ActiveModel::Model
include ActiveModel::Serializers::JSON include ActiveModel::Serializers::JSON
@ -139,19 +139,19 @@ else
end end
end end
class Comment < DummyModel class Comment < BenchmarkModel
attr_accessor :id, :body attr_accessor :id, :body
end end
class Author < DummyModel class Author < BenchmarkModel
attr_accessor :id, :name, :posts attr_accessor :id, :name, :posts
end end
class Post < DummyModel class Post < BenchmarkModel
attr_accessor :id, :title, :body, :comments, :blog, :author attr_accessor :id, :title, :body, :comments, :blog, :author
end end
class Blog < DummyModel class Blog < BenchmarkModel
attr_accessor :id, :name attr_accessor :id, :name
end end
end end