test-prof 0.4.9 → 0.5.0.pre1

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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +63 -20
  3. data/README.md +10 -57
  4. data/assets/tagprof.demo.html +447 -0
  5. data/assets/tagprof.template.html +447 -0
  6. data/lib/minitest/event_prof_formatter.rb +18 -16
  7. data/lib/test_prof.rb +2 -1
  8. data/lib/test_prof/any_fixture.rb +80 -4
  9. data/lib/test_prof/any_fixture/dsl.rb +18 -0
  10. data/lib/test_prof/event_prof.rb +10 -108
  11. data/lib/test_prof/event_prof/custom_events.rb +30 -0
  12. data/lib/test_prof/event_prof/custom_events/factory_create.rb +1 -1
  13. data/lib/test_prof/event_prof/custom_events/sidekiq_inline.rb +1 -1
  14. data/lib/test_prof/event_prof/custom_events/sidekiq_jobs.rb +1 -1
  15. data/lib/test_prof/event_prof/minitest.rb +6 -0
  16. data/lib/test_prof/event_prof/profiler.rb +129 -0
  17. data/lib/test_prof/event_prof/rspec.rb +20 -11
  18. data/lib/test_prof/factory_all_stub.rb +32 -0
  19. data/lib/test_prof/factory_all_stub/factory_bot_patch.rb +13 -0
  20. data/lib/test_prof/factory_doctor/rspec.rb +3 -2
  21. data/lib/test_prof/factory_prof/printers/flamegraph.rb +9 -13
  22. data/lib/test_prof/recipes/active_record_shared_connection.rb +55 -0
  23. data/lib/test_prof/recipes/logging.rb +37 -0
  24. data/lib/test_prof/recipes/rspec/any_fixture.rb +4 -1
  25. data/lib/test_prof/recipes/rspec/factory_all_stub.rb +10 -0
  26. data/lib/test_prof/rspec_dissect/rspec.rb +4 -2
  27. data/lib/test_prof/rspec_stamp/rspec.rb +3 -2
  28. data/lib/test_prof/tag_prof.rb +4 -0
  29. data/lib/test_prof/tag_prof/printers/html.rb +24 -0
  30. data/lib/test_prof/tag_prof/printers/simple.rb +82 -0
  31. data/lib/test_prof/tag_prof/result.rb +38 -0
  32. data/lib/test_prof/tag_prof/rspec.rb +43 -40
  33. data/lib/test_prof/utils/html_builder.rb +21 -0
  34. data/lib/test_prof/version.rb +1 -1
  35. metadata +20 -24
  36. data/assets/logo.svg +0 -1
  37. data/assets/testprof.png +0 -0
  38. data/guides/.rubocop.yml +0 -1
  39. data/guides/any_fixture.md +0 -114
  40. data/guides/before_all.md +0 -98
  41. data/guides/event_prof.md +0 -177
  42. data/guides/factory_default.md +0 -111
  43. data/guides/factory_doctor.md +0 -119
  44. data/guides/factory_prof.md +0 -86
  45. data/guides/let_it_be.md +0 -97
  46. data/guides/rspec_dissect.md +0 -60
  47. data/guides/rspec_stamp.md +0 -52
  48. data/guides/rubocop.md +0 -48
  49. data/guides/ruby_prof.md +0 -63
  50. data/guides/stack_prof.md +0 -47
  51. data/guides/tag_prof.md +0 -51
  52. data/guides/tests_sampling.md +0 -24
@@ -1,51 +0,0 @@
1
- # TagProf
2
-
3
- TagProf is a simple profiler which collects examples statistics grouped by a provided tag value.
4
-
5
- That's pretty useful in conjunction with `rspec-rails` built-in feature – `infer_spec_types_from_location!` – which automatically adds `type` to examples metadata.
6
-
7
- Example output:
8
-
9
- ```sh
10
- [TEST PROF INFO] TagProf report for type
11
-
12
- type time total %total %time avg
13
-
14
- request 00:04.808 42 33.87 54.70 00:00.114
15
- controller 00:02.855 42 33.87 32.48 00:00.067
16
- model 00:01.127 40 32.26 12.82 00:00.028
17
- ```
18
-
19
-
20
- It shows both the total number of examples in each group and the total time spent (as long as percentages and average values).
21
-
22
-
23
- ## Instructions
24
-
25
- TagProf can only be used with RSpec.
26
-
27
- To activate TagProf use `TAG_PROF` environment variable:
28
-
29
- ```sh
30
- # Group by type
31
- TAG_PROF=type rspec
32
- ```
33
-
34
- ## Pro-Tip: More Types
35
-
36
- By default, RSpec only infers types for default Rails app entities (such as controllers, models, mailers, etc.).
37
- Modern Rails applications typically contain other abstractions too (e.g. services, forms, presenters, etc.), but RSpec is not aware of them and doesn't add any metadata.
38
-
39
- That's the quick workaround:
40
-
41
- ```ruby
42
- RSpec.configure do |config|
43
- # ...
44
- config.define_derived_metadata(file_path: %r{/spec/}) do |metadata|
45
- # do not overwrite type if it's already set
46
- next if metadata.key?(:type)
47
- match = metadata[:location].match(%r{/spec/([^/]+)/})
48
- metadata[:type] = match[1].singularize.to_sym
49
- end
50
- end
51
- ```
@@ -1,24 +0,0 @@
1
- # Tests Sampling
2
-
3
- Sometimes it's useful to run profilers against randomly chosen tests. Unfortunetaly, test frameworks don's support such functionality. That's why we've included small patches for RSpec and Minitest in TestProf.
4
-
5
-
6
- ## Instructions
7
-
8
- Require the corresponding patch:
9
-
10
- ```ruby
11
- # For RSpec in your spec_helper.rb
12
- require 'test_prof/recipes/rspec/sample'
13
-
14
- # For Minitest in your test_helper.rb
15
- require 'test_prof/recipes/minitest/sample'
16
- ```
17
-
18
- And then just add `SAMPLE` env variable with the number of example groups (or suites) you want to run:
19
-
20
- ```sh
21
- SAMPLE=10 rspec
22
- ```
23
-
24
- That's it. Enjoy!