abprof 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae747acd5bc96fca3eafd6e0a1a8b0ba2d4ef62b
4
- data.tar.gz: ae5cfee49428221a97f8c45935ef967e3072473a
3
+ metadata.gz: 0c46230d0f2b162c58c08527cac952ecef8c9396
4
+ data.tar.gz: 71aa9aeeac60e757c1074fa34dc527093ea67dae
5
5
  SHA512:
6
- metadata.gz: 201b109cc93df7c18fe8d219ef6e3966abd8236bd950ca6a080a11c1c54d590506de62bb012e1b70cb540847ed50c7779ce7c3ac075328e3459a2b35501e049c
7
- data.tar.gz: e79d72f6a0e8c5d439f250bd90755ca770b55c979229b983d9f3c64ce3c43500aaf724d4362ad3cc0107642c1775d8699b40cc4ab802a442c721bb24b5cdbc98
6
+ metadata.gz: fc6ace0578b40b801af81ebd1e3b315005c43d308a855e07bc5289676bf8ebd2dd47ba5162a3a51a26dcec562442ee701c388e9274d3d60e02528ad9954b69d2
7
+ data.tar.gz: 1c0c034f694218c58714f4fbd050216b423129cc763b44f5c7cfe48d237616ed82b4701617845862be5bbca7c34efbcfd599e18bdb324c33254fd30c70155e44
data/README.md CHANGED
@@ -16,6 +16,17 @@ set of measured runtimes to determine how likely the two programs are
16
16
  to be different from each other, and after the P value is low enough,
17
17
  we give our current estimate of which is faster and by how much.
18
18
 
19
+ Want a nice "getting started" introduction? Here are the original blog
20
+ posts on using ABProf.
21
+
22
+ * <a href="https://appfolio-engineering.squarespace.com/appfolio-engineering/2016/7/18/profiling-ruby-like-an-ab-tester">Profiling Ruby Like an A/B Tester</a>
23
+ * <a href="https://appfolio-engineering.squarespace.com/appfolio-engineering/2016/8/8/abprof-an-accurate-statistical-profiling-harness">ABProf: An Accurate Statistical Profiling Harness</a>
24
+
25
+ For more about the subtleties of profiling in general, may I recommend
26
+ <a href="https://www.youtube.com/watch?v=kJDOpucaUR4">Matthew Gaudet's
27
+ wonderful talk "Ruby 3x3: How Will Are We Going To Measure 3X?" from
28
+ RubyKaigi 2016?</a>
29
+
19
30
  ## Installation
20
31
 
21
32
  Add this line to your application's Gemfile:
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "trollop"
4
+ require "abprof"
5
+ require "abprof/benchmark_dsl"
6
+
7
+ OPTS = Trollop::options do
8
+ banner <<BANNER
9
+ Specify a first and second command line, and (often) a p-value or other
10
+ parameters.
11
+
12
+ Example: #{$0} examples/sleep.rb examples/sleep_longer.rb
13
+
14
+ The first and second commands are the first two arguments. You'll need to
15
+ quote multi-word commands, as is normal in bash.
16
+
17
+ Specifying lots of iterations and trials, high burn-in and a low P value
18
+ is accurate, but slow.
19
+
20
+ Specifying low iterations, trials and burn-in and a high P value gives
21
+ quick, rough results early on.
22
+
23
+ Specifying more iterations per trial is good for highly variable iteration
24
+ timing.
25
+
26
+ Specifying a lower max number of trials keeps the test from running *too*
27
+ long when the two are identical.
28
+
29
+ Specifying a high burn-in is necessary when cache behavior changes timing
30
+ significantly.
31
+
32
+ Vast numbers of trials can nearly always occasionally show differences
33
+ *somewhere* along the line, just by random chance. To avoid this, pick how
34
+ many samples first, run them all in one go, and then just check the p value
35
+ once.
36
+
37
+ A p value is often interpreted as the probability we got a wrong answer.
38
+ That's an oversimplification, but not (usually) a terrible one.
39
+ BANNER
40
+ opt :debug, "Print more output to console"
41
+ opt :bare, "Use bare command-line commands, no Ruby harness", :default => ($0["compare"])
42
+ opt :pvalue, "P value (certainty) for Welch's T test", :default => 0.05
43
+ opt :burnin, "'Burn in' repetitions before real trials", :default => 10
44
+ opt :min_trials, "Minimum number of sample sets from each process", :default => 1
45
+ opt :max_trials, "Maximum number of sample sets from each process", :default => 20
46
+ opt :iters_per_trial, "Iterations per sample set", :default => 10
47
+ opt :print_samples, "Print all sample values for later analysis.", :default => false
48
+ opt :fail_on_divergence, "Return a non-zero code if pvalue is greater than specified."
49
+ opt :static_order, "Don't randomize the order of sampled processes per trial."
50
+ end
51
+
52
+ if ARGV.length != 2
53
+ puts "Must specify both commands as normal arguments!"
54
+ exit -1
55
+ end
56
+
57
+ command1, command2 = ARGV
58
+
59
+ # Create DSL configuration for known properties,
60
+ # but don't actually run the sampling yet.
61
+ bm_inst = ABProf.compare(:no_at_exit => true) do
62
+ pvalue OPTS[:pvalue]
63
+ burnin OPTS[:burnin]
64
+ min_trials OPTS[:min_trials]
65
+ max_trials OPTS[:max_trials]
66
+ iters_per_trial OPTS[:iters_per_trial]
67
+ bare OPTS[:bare]
68
+ debug OPTS[:debug]
69
+ static_order OPTS[:static_order]
70
+ # No fail_on_divergence - we do this manually for the CLI utilities
71
+
72
+ report_command command1
73
+ report_command command2
74
+ end
75
+
76
+ state = bm_inst.run_sampling(:print_output => true)
77
+ p_val = state[:p_tests][-1]
78
+
79
+ if OPTS[:print_samples]
80
+ puts "Samples for P1: #{state[:samples][0].inspect}"
81
+ puts "Samples for P2: #{state[:samples][1].inspect}"
82
+ end
83
+
84
+ exit 2 if (p_val >= bm_inst.p_value) && OPTS[:fail_on_divergence]
85
+
86
+ # Otherwise, return success
@@ -1,3 +1,3 @@
1
1
  module Abprof
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abprof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Gibbs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-15 00:00:00.000000000 Z
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -1 +0,0 @@
1
- abprof