From 666756f7798ef85cfbbf8241add2b346dc7153ad Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Wed, 9 Mar 2016 21:55:33 -0600 Subject: [PATCH] Rename dummy to benchmark --- bin/bench | 2 +- bin/{serve_dummy => serve_benchmark} | 16 ++++++++-------- test/{dummy => benchmark}/app.rb | 4 ++-- .../{dummy => benchmark}/benchmarking_support.rb | 2 +- test/{dummy => benchmark}/bm_caching.rb | 0 test/{dummy => benchmark}/config.ru | 0 test/{dummy => benchmark}/controllers.rb | 4 ++-- test/{dummy => benchmark}/fixtures.rb | 10 +++++----- 8 files changed, 19 insertions(+), 19 deletions(-) rename bin/{serve_dummy => serve_benchmark} (53%) rename test/{dummy => benchmark}/app.rb (95%) rename test/{dummy => benchmark}/benchmarking_support.rb (95%) rename test/{dummy => benchmark}/bm_caching.rb (100%) rename test/{dummy => benchmark}/config.ru (100%) rename test/{dummy => benchmark}/controllers.rb (94%) rename test/{dummy => benchmark}/fixtures.rb (96%) diff --git a/bin/bench b/bin/bench index 63cccc46..b2e99b40 100755 --- a/bin/bench +++ b/bin/bench @@ -15,7 +15,7 @@ require 'English' class BenchmarkDriver 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) def self.benchmark(options) diff --git a/bin/serve_dummy b/bin/serve_benchmark similarity index 53% rename from bin/serve_dummy rename to bin/serve_benchmark index 960a7126..3f292d18 100755 --- a/bin/serve_dummy +++ b/bin/serve_benchmark @@ -4,18 +4,18 @@ set -e case "$1" in start) - config="${CONFIG_RU:-test/dummy/config.ru}" - bundle exec ruby -Ilib -S rackup "$config" --daemonize --pid tmp/dummy_app.pid --warn --server webrick - until [ -f 'tmp/dummy_app.pid' ]; do + config="${CONFIG_RU:-test/benchmark/config.ru}" + bundle exec ruby -Ilib -S rackup "$config" --daemonize --pid tmp/benchmark_app.pid --warn --server webrick + until [ -f 'tmp/benchmark_app.pid' ]; do sleep 0.1 # give it time to start.. I don't know a better way done - cat tmp/dummy_app.pid + cat tmp/benchmark_app.pid true ;; stop) - if [ -f 'tmp/dummy_app.pid' ]; then - kill -TERM $(cat tmp/dummy_app.pid) + if [ -f 'tmp/benchmark_app.pid' ]; then + kill -TERM $(cat tmp/benchmark_app.pid) else echo 'No pidfile' false @@ -23,8 +23,8 @@ case "$1" in ;; status) - if [ -f 'tmp/dummy_app.pid' ]; then - kill -0 $(cat tmp/dummy_app.pid) + if [ -f 'tmp/benchmark_app.pid' ]; then + kill -0 $(cat tmp/benchmark_app.pid) [ "$?" -eq 0 ] else echo 'No pidfile' diff --git a/test/dummy/app.rb b/test/benchmark/app.rb similarity index 95% rename from test/dummy/app.rb rename to test/benchmark/app.rb index ae110ec3..bc0d3689 100644 --- a/test/dummy/app.rb +++ b/test/benchmark/app.rb @@ -18,7 +18,7 @@ class NullLogger < Logger def add(*_args, &_block) end end -class DummyLogger < ActiveSupport::Logger +class BenchmarkLogger < ActiveSupport::Logger def initialize @file = StringIO.new super(@file) @@ -30,7 +30,7 @@ class DummyLogger < ActiveSupport::Logger end end # ref: https://gist.github.com/bf4/8744473 -class DummyApp < Rails::Application +class BenchmarkApp < Rails::Application # Set up production configuration config.eager_load = true config.cache_classes = true diff --git a/test/dummy/benchmarking_support.rb b/test/benchmark/benchmarking_support.rb similarity index 95% rename from test/dummy/benchmarking_support.rb rename to test/benchmark/benchmarking_support.rb index 11c78e68..483294da 100644 --- a/test/dummy/benchmarking_support.rb +++ b/test/benchmark/benchmarking_support.rb @@ -7,7 +7,7 @@ module Benchmark module ActiveModelSerializers module TestMethods 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]) fail "omg, #{method}, #{path}, '#{response.status}', '#{response.body}'" end diff --git a/test/dummy/bm_caching.rb b/test/benchmark/bm_caching.rb similarity index 100% rename from test/dummy/bm_caching.rb rename to test/benchmark/bm_caching.rb diff --git a/test/dummy/config.ru b/test/benchmark/config.ru similarity index 100% rename from test/dummy/config.ru rename to test/benchmark/config.ru diff --git a/test/dummy/controllers.rb b/test/benchmark/controllers.rb similarity index 94% rename from test/dummy/controllers.rb rename to test/benchmark/controllers.rb index 4ea88f6b..9d7934e5 100644 --- a/test/dummy/controllers.rb +++ b/test/benchmark/controllers.rb @@ -35,7 +35,7 @@ class PostController < ActionController::Base ActionController::Base.cache_store.clear # Test caching is on # 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 # # 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 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 def toggle_cache_status diff --git a/test/dummy/fixtures.rb b/test/benchmark/fixtures.rb similarity index 96% rename from test/dummy/fixtures.rb rename to test/benchmark/fixtures.rb index 4ba350b8..bdba919b 100644 --- a/test/dummy/fixtures.rb +++ b/test/benchmark/fixtures.rb @@ -104,7 +104,7 @@ else # ActiveModelSerializers::Model is a convenient # serializable class to inherit from when making # serializable non-activerecord objects. - class DummyModel + class BenchmarkModel include ActiveModel::Model include ActiveModel::Serializers::JSON @@ -139,19 +139,19 @@ else end end - class Comment < DummyModel + class Comment < BenchmarkModel attr_accessor :id, :body end - class Author < DummyModel + class Author < BenchmarkModel attr_accessor :id, :name, :posts end - class Post < DummyModel + class Post < BenchmarkModel attr_accessor :id, :title, :body, :comments, :blog, :author end - class Blog < DummyModel + class Blog < BenchmarkModel attr_accessor :id, :name end end