rubytune / perf_check

PERRRFFF CHERRRRK!
17 stars 7 forks source link

Added new config --compare-paths #18

Closed edanc closed 7 years ago

edanc commented 7 years ago

Sometimes I want to check whether a new path performs better than an old path. This new config allows that :)

usage perf_check /posts/ /posts/1 --compare_paths New config compares paths to each other

Example:

 test_app git:(add_compare_path) be perf_check /posts/1 /posts -n2 --compare-paths
[2017-05-27 15:07:56] starting rails...
[2017-05-27 15:08:04] =============================================================================
[2017-05-27 15:08:04] PERRRRF CHERRRK! Grab a ☕️   and don't touch your working tree (we automate git)
[2017-05-27 15:08:04] =============================================================================
[2017-05-27 15:08:04] re-starting rails...
[2017-05-27 15:08:14]
[2017-05-27 15:08:14] Benchmarking /posts/1:
[2017-05-27 15:08:14]   request   latency   server rss   status   queries   profiler data
[2017-05-27 15:08:14]    1:       16.0ms     63MB         200      1       /mini-profiler-resources/results?id=9rbsa8tpakn4kloy7w30
[2017-05-27 15:08:14]    2:       15.7ms     64MB         200      1       /mini-profiler-resources/results?id=77ucubu28k04he7ba1ct
[2017-05-27 15:08:14]
[2017-05-27 15:08:14] =============================================================================
[2017-05-27 15:08:14] PERRRRF CHERRRK! Grab a ☕️  and don't touch your working tree (we automate git)
[2017-05-27 15:08:14] =============================================================================
[2017-05-27 15:08:14] re-starting rails...
[2017-05-27 15:08:24]
[2017-05-27 15:08:24] Benchmarking /posts:
[2017-05-27 15:08:24]   request   latency   server rss   status   queries   profiler data
[2017-05-27 15:08:28]    1:       1724.7ms     68MB       200      5500    /mini-profiler-resources/results?id=kom96rt9xfeel59wvrj0
[2017-05-27 15:08:29]    2:       1710.5ms     70MB       200      5500    /mini-profiler-resources/results?id=98d797j7jv6b512ushav
[2017-05-27 15:08:29]
[2017-05-27 15:08:31] Checking out add_compare_path and bundling...
first path:/posts/1
second path:/posts
  second path: 1717.6ms
   first path: 15.8ms
       change: -1701.7ms (yours is 108.4x faster!)
edanc commented 7 years ago

@sudara @wioux

nathanbertram commented 7 years ago

We'll need to fix the specs before merging this one in

edanc commented 7 years ago

@nathanbertram @sudara i ran the specs in master and got these errors

Failures:

  1) PerfCheck::Git#stash_if_needed should call git stash if there are changes
     Failure/Error: expect(`git stash list`.lines.size).to eq(1)

       expected: 1
            got: 8

       (compared using ==)
     # ./spec/perf_check/git_spec.rb:107:in `block (3 levels) in <top (required)>'

  2) PerfCheck::Git#migrations_to_run_down should list those versions on current_branch which are not on master
     Failure/Error: expect(git.migrations_to_run_down).to eq(["12345"])

       expected: ["12345"]
            got: []

       (compared using ==)
     # ./spec/perf_check/git_spec.rb:139:in `block (3 levels) in <top (required)>'

  3) PerfCheck::Middleware#call when backend raises exception should insert X-PerfCheck-StackTrace header with path to backtrace
     Failure/Error: expect(middleware.app).to receive(:call).with(env){ raise Exception.new }

     Exception:
       Exception
     # ./spec/perf_check/middleware_spec.rb:32:in `block (5 levels) in <top (required)>'
     # ./lib/perf_check/middleware.rb:19:in `call'
     # ./spec/perf_check/middleware_spec.rb:33:in `block (4 levels) in <top (required)>'

  4) PerfCheck#load_config should rescue exceptions from the config file
     Failure/Error: expect{ perf_check.load_config }.to raise_error(PerfCheck::ConfigLoadError)

       expected PerfCheck::ConfigLoadError, got #<LoadError: cannot load such file -- tmp/spec/config/perf_check.rb> with backtrace:
         # ./lib/perf_check.rb:53:in `load'
         # ./lib/perf_check.rb:53:in `load_config'
         # ./spec/perf_check_spec.rb:24:in `block (4 levels) in <top (required)>'
         # ./spec/perf_check_spec.rb:24:in `block (3 levels) in <top (required)>'
     # ./spec/perf_check_spec.rb:24:in `block (3 levels) in <top (required)>'

Finished in 2 minutes 43.8 seconds (files took 0.2189 seconds to load)
69 examples, 4 failures, 11 pending

Failed examples:

rspec ./spec/perf_check/git_spec.rb:99 # PerfCheck::Git#stash_if_needed should call git stash if there are changes
rspec ./spec/perf_check/git_spec.rb:131 # PerfCheck::Git#migrations_to_run_down should list those versions on current_branch which are not on master
rspec ./spec/perf_check/middleware_spec.rb:31 # PerfCheck::Middleware#call when backend raises exception should insert X-PerfCheck-StackTrace header with path to backtrace
rspec ./spec/perf_check_spec.rb:19 # PerfCheck#load_config should rescue exceptions from the config file

Can you confirm that they fail for you too.

sudara commented 7 years ago

Specs in master are now green (not yet in CI, working on that!) — so this is next on my radar!