u-case 3.0.0.rc9 → 4.1.1

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
  SHA256:
3
- metadata.gz: 758ce4bd700ff2d362bcec72b000f6c8b7cccd948c65ad43aa62e7af5c41f924
4
- data.tar.gz: bcbcb6638c5fe9edfc9853fcb6099a485df322a491d96f81f6f9278c33dba98d
3
+ metadata.gz: feb30aaeb689640c0e2690c14e9f951896ced470bb3a9d31262c6441a37e3e57
4
+ data.tar.gz: 7fceb73bac6e4f6bc82558636679ad646c7c454e8ff516bb920632fb2e1c29a6
5
5
  SHA512:
6
- metadata.gz: ed85f77d590791c8191df21bd96a12b55e2bf12ff269fd2ebe6a2103f4ce0d6cbe624b47a42eda0910bcaf0b8676770590cf1be87d86a201a0cbbf9d5a2597b7
7
- data.tar.gz: 5dae9cdb67a90ada4dbe0b4f6f1c87ee5a5029331e25aa16cecfaaab416458bf4591fa80b2ddf466a5445312484513ce59ef6b93f3bc3ab951e4742139d4d77c
6
+ metadata.gz: 27d50ac0ce1cb8129f752d181a5707bfe3ac8c2e2228448945d5d80b4b4cb7d6481b4b9a860bb9c686e34306c6aed0acb2a65fb507a807882f2de128bee7cfbd
7
+ data.tar.gz: 0fca08fe550b5519f3a754b529e2e636b04a9433be093219526fab694596d431950f308c5a4f322b0a7810ec63a448ce8feec230dab60d405465c57c19e5c8ea
data/.travis.sh CHANGED
@@ -3,21 +3,21 @@
3
3
  ruby_v=$(ruby -v)
4
4
 
5
5
  ACTIVEMODEL_VERSION='3.2' bundle update
6
- ACTIVEMODEL_VERSION='3.2' ENABLE_TRANSITIONS='true' bundle exec rake test
7
6
  ACTIVEMODEL_VERSION='3.2' ENABLE_TRANSITIONS='false' bundle exec rake test
7
+ ACTIVEMODEL_VERSION='3.2' ENABLE_TRANSITIONS='true' bundle exec rake test
8
8
 
9
9
  if [[ ! $ruby_v =~ '2.2.0' ]]; then
10
10
  ACTIVEMODEL_VERSION='5.2' bundle update
11
- ACTIVEMODEL_VERSION='5.2' ENABLE_TRANSITIONS='true' bundle exec rake test
12
11
  ACTIVEMODEL_VERSION='5.2' ENABLE_TRANSITIONS='false' bundle exec rake test
12
+ ACTIVEMODEL_VERSION='5.2' ENABLE_TRANSITIONS='true' bundle exec rake test
13
13
  fi
14
14
 
15
15
  if [[ $ruby_v =~ '2.5.' ]] || [[ $ruby_v =~ '2.6.' ]] || [[ $ruby_v =~ '2.7.' ]]; then
16
16
  ACTIVEMODEL_VERSION='6.0' bundle update
17
- ACTIVEMODEL_VERSION='6.0' ENABLE_TRANSITIONS='true' bundle exec rake test
18
17
  ACTIVEMODEL_VERSION='6.0' ENABLE_TRANSITIONS='false' bundle exec rake test
18
+ ACTIVEMODEL_VERSION='6.0' ENABLE_TRANSITIONS='true' bundle exec rake test
19
19
  fi
20
20
 
21
21
  bundle update
22
- ENABLE_TRANSITIONS='true' bundle exec rake test
23
22
  ENABLE_TRANSITIONS='false' bundle exec rake test
23
+ ENABLE_TRANSITIONS='true' bundle exec rake test
data/Gemfile CHANGED
@@ -15,9 +15,17 @@ if activemodel_version < '6.1.0'
15
15
  gem 'activesupport', activemodel, require: false
16
16
  end
17
17
 
18
+ simplecov_version =
19
+ case RUBY_VERSION
20
+ when /\A2.[23]/ then '~> 0.17.1'
21
+ when /\A2.4/ then '~> 0.18.5'
22
+ else '~> 0.19'
23
+ end
24
+
18
25
  group :test do
19
26
  gem 'minitest', activemodel_version < '4.1' ? '~> 4.2' : '~> 5.0'
20
- gem 'simplecov', require: false
27
+
28
+ gem 'simplecov', simplecov_version, require: false
21
29
  end
22
30
 
23
31
  pry_byebug_version =
data/README.md CHANGED
@@ -1,12 +1,29 @@
1
- ![Ruby](https://img.shields.io/badge/ruby-2.2+-ruby.svg?colorA=99004d&colorB=cc0066)
2
- [![Gem](https://img.shields.io/gem/v/u-case.svg?style=flat-square)](https://rubygems.org/gems/u-case)
3
- [![Build Status](https://travis-ci.com/serradura/u-case.svg?branch=main)](https://travis-ci.com/serradura/u-case)
4
- [![Maintainability](https://api.codeclimate.com/v1/badges/5c3c8ad1b0b943f88efd/maintainability)](https://codeclimate.com/github/serradura/u-case/maintainability)
5
- [![Test Coverage](https://api.codeclimate.com/v1/badges/5c3c8ad1b0b943f88efd/test_coverage)](https://codeclimate.com/github/serradura/u-case/test_coverage)
1
+ <p align="center">
2
+ <img src="./assets/ucase_logo_v1.png" alt="u-case - Represent use cases in a simple and powerful way while writing modular, expressive and sequentially logical code.">
6
3
 
7
- <img src="./assets/ucase_logo_v1.png" alt="u-case - Create simple and powerful use cases as Ruby objects.">
4
+ <p align="center"><i>Represent use cases in a simple and powerful way while writing modular, expressive and sequentially logical code.</i></p>
5
+ <br>
6
+ </p>
8
7
 
9
- Create simple and powerful use cases as Ruby objects.
8
+ <p align="center">
9
+ <img src="https://img.shields.io/badge/ruby->%3D%202.2.0-ruby.svg?colorA=99004d&colorB=cc0066" alt="Ruby">
10
+
11
+ <a href="https://rubygems.org/gems/u-case">
12
+ <img alt="Gem" src="https://img.shields.io/gem/v/u-case.svg?style=flat-square">
13
+ </a>
14
+
15
+ <a href="https://travis-ci.com/serradura/u-case">
16
+ <img alt="Build Status" src="https://travis-ci.com/serradura/u-case.svg?branch=main">
17
+ </a>
18
+
19
+ <a href="https://codeclimate.com/github/serradura/u-case/maintainability">
20
+ <img alt="Maintainability" src="https://api.codeclimate.com/v1/badges/5c3c8ad1b0b943f88efd/maintainability">
21
+ </a>
22
+
23
+ <a href="https://codeclimate.com/github/serradura/u-case/test_coverage">
24
+ <img alt="Test Coverage" src="https://api.codeclimate.com/v1/badges/5c3c8ad1b0b943f88efd/test_coverage">
25
+ </a>
26
+ </p>
10
27
 
11
28
  The main project goals are:
12
29
  1. Easy to use and easy to learn (input **>>** process **>>** output).
@@ -21,7 +38,9 @@ The main project goals are:
21
38
 
22
39
  Version | Documentation
23
40
  --------- | -------------
24
- 3.0.0.rc9 | https://github.com/serradura/u-case/blob/main/README.md
41
+ unreleased| https://github.com/serradura/u-case/blob/main/README.md
42
+ 4.1.1 | https://github.com/serradura/u-case/blob/v4.x/README.md
43
+ 3.1.0 | https://github.com/serradura/u-case/blob/v3.x/README.md
25
44
  2.6.0 | https://github.com/serradura/u-case/blob/v2.x/README.md
26
45
  1.1.0 | https://github.com/serradura/u-case/blob/v1.x/README.md
27
46
 
@@ -60,10 +79,13 @@ Version | Documentation
60
79
  - [`Kind::Validator`](#kindvalidator)
61
80
  - [`Micro::Case.config`](#microcaseconfig)
62
81
  - [Benchmarks](#benchmarks)
63
- - [`Micro::Case` (v3.0.0)](#microcase-v300)
82
+ - [`Micro::Case`](#microcase)
64
83
  - [Success results](#success-results)
65
84
  - [Failure results](#failure-results)
66
- - [`Micro::Cases::Flow` (v3.0.0)](#microcasesflow-v300)
85
+ - [`Micro::Cases::Flow`](#microcasesflow)
86
+ - [Running the benchmarks](#running-the-benchmarks)
87
+ - [Performance (Benchmarks IPS)](#performance-benchmarks-ips)
88
+ - [Memory profiling](#memory-profiling)
67
89
  - [Comparisons](#comparisons)
68
90
  - [Examples](#examples)
69
91
  - [1️⃣ Users creation](#1️⃣-users-creation)
@@ -77,11 +99,13 @@ Version | Documentation
77
99
 
78
100
  ## Compatibility
79
101
 
80
- | u-case | branch | ruby | activemodel |
81
- | -------------- | ------- | -------- | ------------- |
82
- | 3.0.0.rc9 | main | >= 2.2.0 | >= 3.2, < 6.1 |
83
- | 2.6.0 | v2.x | >= 2.2.0 | >= 3.2, < 6.1 |
84
- | 1.1.0 | v1.x | >= 2.2.0 | >= 3.2, < 6.1 |
102
+ | u-case | branch | ruby | activemodel | u-attributes |
103
+ | -------------- | ------- | -------- | ------------- | ------------ |
104
+ | unreleased | main | >= 2.2.0 | >= 3.2, < 6.1 | ~> 2.0 |
105
+ | 4.1.1 | v4.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 2.0 |
106
+ | 3.1.0 | v3.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
107
+ | 2.6.0 | v2.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
108
+ | 1.1.0 | v1.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
85
109
 
86
110
  > Note: The activemodel is an optional dependency, this module [can be enabled](#u-casewith_activemodel_validation---how-to-validate-use-case-attributes) to validate the use cases' attributes.
87
111
 
@@ -102,7 +126,7 @@ Version | Documentation
102
126
  Add this line to your application's Gemfile:
103
127
 
104
128
  ```ruby
105
- gem 'u-case', '~> 3.0.0.rc9'
129
+ gem 'u-case', '~> 4.1.0'
106
130
  ```
107
131
 
108
132
  And then execute:
@@ -111,7 +135,7 @@ And then execute:
111
135
 
112
136
  Or install it yourself as:
113
137
 
114
- $ gem install u-case --pre
138
+ $ gem install u-case
115
139
 
116
140
  ## Usage
117
141
 
@@ -1060,7 +1084,7 @@ class Multiply < Micro::Case
1060
1084
  validates :a, :b, presence: true, numericality: true
1061
1085
 
1062
1086
  def call!
1063
- return Failure :validation_error, result: { errors: self.errors } if invalid?
1087
+ return Failure :invalid_attributes, result: { errors: self.errors } if invalid?
1064
1088
 
1065
1089
  Success result: { number: a * b }
1066
1090
  end
@@ -1170,110 +1194,112 @@ end
1170
1194
 
1171
1195
  ## Benchmarks
1172
1196
 
1173
- ### `Micro::Case` (v3.0.0)
1197
+ ### `Micro::Case`
1174
1198
 
1175
1199
  #### Success results
1176
1200
 
1177
1201
  | Gem / Abstraction | Iterations per second | Comparison |
1178
1202
  | ----------------- | --------------------: | ----------------: |
1179
- | Dry::Monads | 141730.1 | _**The Fastest**_ |
1180
- | **Micro::Case** | 103541.3 | 1.37x slower |
1181
- | Interactor | 29100.8 | 4.87x slower |
1182
- | Trailblazer::Operation | 15031.4 | 9.43x slower |
1183
- | Dry::Transaction | 5674.0 | 24.98x slower |
1203
+ | Dry::Monads | 315635.1 | _**The Fastest**_ |
1204
+ | **Micro::Case** | 75837.7 | 4.16x slower |
1205
+ | Interactor | 59745.5 | 5.28x slower |
1206
+ | Trailblazer::Operation | 28423.9 | 11.10x slower |
1207
+ | Dry::Transaction | 10130.9 | 31.16x slower |
1184
1208
 
1185
1209
  <details>
1186
1210
  <summary>Show the full <a href="https://github.com/evanphx/benchmark-ips">benchmark/ips</a> results.</summary>
1187
1211
 
1188
1212
  ```ruby
1189
1213
  # Warming up --------------------------------------
1190
- # Interactor 2.915k i/100ms
1191
- # Trailblazer::Operation 1.543k i/100ms
1192
- # Dry::Monads 14.288k i/100ms
1193
- # Dry::Transaction 571.000 i/100ms
1194
- # Micro::Case 10.418k i/100ms
1195
- # Micro::Case::Strict 8.296k i/100ms
1196
- # Micro::Case::Safe 10.254k i/100ms
1214
+ # Interactor 5.711k i/100ms
1215
+ # Trailblazer::Operation
1216
+ # 2.283k i/100ms
1217
+ # Dry::Monads 31.130k i/100ms
1218
+ # Dry::Transaction 994.000 i/100ms
1219
+ # Micro::Case 7.911k i/100ms
1220
+ # Micro::Case::Safe 7.911k i/100ms
1221
+ # Micro::Case::Strict 6.248k i/100ms
1197
1222
 
1198
1223
  # Calculating -------------------------------------
1199
- # Interactor 29.101k 2.1%) i/s - 145.750k in 5.010660s
1200
- # Trailblazer::Operation 15.031k (± 2.0%) i/s - 75.607k in 5.032071s
1201
- # Dry::Monads 141.730k 3.1%) i/s - 714.400k in 5.045546s
1202
- # Dry::Transaction 5.674k (± 1.9%) i/s - 28.550k in 5.033564s
1203
- # Micro::Case 103.541k1.6%) i/s - 520.900k in 5.032077s
1204
- # Micro::Case::Strict 83.045k2.4%) i/s - 423.096k in 5.098031s
1205
- # Micro::Case::Safe 101.662k 1.5%) i/s - 512.700k in 5.044386s
1224
+ # Interactor 59.746k29.9%) i/s - 274.128k in 5.049901s
1225
+ # Trailblazer::Operation
1226
+ # 28.424k15.8%) i/s - 141.546k in 5.087882s
1227
+ # Dry::Monads 315.635k6.1%) i/s - 1.588M in 5.048914s
1228
+ # Dry::Transaction 10.131k6.4%) i/s - 50.694k in 5.025150s
1229
+ # Micro::Case 75.838k9.7%) i/s - 379.728k in 5.052573s
1230
+ # Micro::Case::Safe 75.461k10.1%) i/s - 379.728k in 5.079238s
1231
+ # Micro::Case::Strict 64.235k (± 9.0%) i/s - 324.896k in 5.097028s
1206
1232
 
1207
1233
  # Comparison:
1208
- # Dry::Monads: 141730.1 i/s
1209
- # Micro::Case: 103541.3 i/s - 1.37x (± 0.00) slower
1210
- # Micro::Case::Safe: 101662.2 i/s - 1.39x (± 0.00) slower
1211
- # Micro::Case::Strict: 83044.6 i/s - 1.71x (± 0.00) slower
1212
- # Interactor: 29100.8 i/s - 4.87x (± 0.00) slower
1213
- # Trailblazer::Operation: 15031.4 i/s - 9.43x (± 0.00) slower
1214
- # Dry::Transaction: 5674.0 i/s - 24.98x (± 0.00) slower
1234
+ # Dry::Monads: 315635.1 i/s
1235
+ # Micro::Case: 75837.7 i/s - 4.16x (± 0.00) slower
1236
+ # Micro::Case::Safe: 75461.3 i/s - 4.18x (± 0.00) slower
1237
+ # Micro::Case::Strict: 64234.9 i/s - 4.91x (± 0.00) slower
1238
+ # Interactor: 59745.5 i/s - 5.28x (± 0.00) slower
1239
+ # Trailblazer::Operation: 28423.9 i/s - 11.10x (± 0.00) slower
1240
+ # Dry::Transaction: 10130.9 i/s - 31.16x (± 0.00) slower
1215
1241
  ```
1216
1242
  </details>
1217
1243
 
1218
- https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_success_result.rb
1244
+ https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/use_case/success_results.rb
1219
1245
 
1220
1246
  #### Failure results
1221
1247
 
1222
1248
  | Gem / Abstraction | Iterations per second | Comparison |
1223
1249
  | ----------------- | --------------------: | ----------------: |
1224
- | **Micro::Case** | 98820.8 | _**The Fastest**_ |
1225
- | Dry::Monads | 71329.7 | 1.39x slower |
1226
- | Trailblazer::Operation | 15034.9 | 6.57x slower |
1227
- | Interactor | 13958.7 | 7.08x slower |
1228
- | Dry::Transaction | 5067.5 | 19.50x slower |
1250
+ | Dry::Monads | 135386.9 | _**The Fastest**_ |
1251
+ | **Micro::Case** | 73489.3 | 1.85x slower |
1252
+ | Trailblazer::Operation | 29016.4 | 4.67x slower |
1253
+ | Interactor | 27037.0 | 5.01x slower |
1254
+ | Dry::Transaction | 8988.6 | 15.06x slower |
1229
1255
 
1230
1256
  <details>
1231
1257
  <summary>Show the full <a href="https://github.com/evanphx/benchmark-ips">benchmark/ips</a> results.</summary>
1232
1258
 
1233
1259
  ```ruby
1234
1260
  # Warming up --------------------------------------
1235
- # Interactor 1.324k i/100ms
1236
- # Trailblazer::Operation 1.525k i/100ms
1237
- # Dry::Monads 7.126k i/100ms
1238
- # Dry::Transaction 499.000 i/100ms
1239
- # Micro::Case 9.919k i/100ms
1240
- # Micro::Case::Strict 7.837k i/100ms
1241
- # Micro::Case::Safe 9.762k i/100ms
1261
+ # Interactor 2.626k i/100ms
1262
+ # Trailblazer::Operation 2.343k i/100ms
1263
+ # Dry::Monads 13.386k i/100ms
1264
+ # Dry::Transaction 868.000 i/100ms
1265
+ # Micro::Case 7.603k i/100ms
1266
+ # Micro::Case::Safe 7.598k i/100ms
1267
+ # Micro::Case::Strict 6.178k i/100ms
1242
1268
 
1243
1269
  # Calculating -------------------------------------
1244
- # Interactor 13.959k 2.5%) i/s - 70.172k in 5.030240s
1245
- # Trailblazer::Operation 15.035k 2.2%) i/s - 76.250k in 5.074108s
1246
- # Dry::Monads 71.330k 2.4%) i/s - 363.426k in 5.097993s
1247
- # Dry::Transaction 5.068k1.9%) i/s - 25.449k in 5.023922s
1248
- # Micro::Case 98.821k2.9%) i/s - 495.950k in 5.023421s
1249
- # Micro::Case::Strict 79.936k3.1%) i/s - 399.687k in 5.005435s
1250
- # Micro::Case::Safe 98.695k1.9%) i/s - 497.862k in 5.046246s
1270
+ # Interactor 27.037k24.9%) i/s - 128.674k in 5.102133s
1271
+ # Trailblazer::Operation 29.016k12.4%) i/s - 145.266k in 5.074991s
1272
+ # Dry::Monads 135.387k15.1%) i/s - 669.300k in 5.055356s
1273
+ # Dry::Transaction 8.989k9.2%) i/s - 45.136k in 5.084820s
1274
+ # Micro::Case 73.247k9.9%) i/s - 364.944k in 5.030449s
1275
+ # Micro::Case::Safe 73.489k9.6%) i/s - 364.704k in 5.007282s
1276
+ # Micro::Case::Strict 61.980k8.0%) i/s - 308.900k in 5.014821s
1251
1277
 
1252
1278
  # Comparison:
1253
- # Micro::Case: 98820.8 i/s
1254
- # Micro::Case::Safe: 98695.0 i/s - same-ish: difference falls within error
1255
- # Micro::Case::Strict: 79935.9 i/s - 1.24x (± 0.00) slower
1256
- # Dry::Monads: 71329.7 i/s - 1.39x (± 0.00) slower
1257
- # Trailblazer::Operation: 15034.9 i/s - 6.57x (± 0.00) slower
1258
- # Interactor: 13958.7 i/s - 7.08x (± 0.00) slower
1259
- # Dry::Transaction: 5067.5 i/s - 19.50x (± 0.00) slower
1279
+ # Dry::Monads: 135386.9 i/s
1280
+ # Micro::Case::Safe: 73489.3 i/s - 1.84x (± 0.00) slower
1281
+ # Micro::Case: 73246.6 i/s - 1.85x (± 0.00) slower
1282
+ # Micro::Case::Strict: 61979.7 i/s - 2.18x (± 0.00) slower
1283
+ # Trailblazer::Operation: 29016.4 i/s - 4.67x (± 0.00) slower
1284
+ # Interactor: 27037.0 i/s - 5.01x (± 0.00) slower
1285
+ # Dry::Transaction: 8988.6 i/s - 15.06x (± 0.00) slower
1260
1286
  ```
1261
1287
  </details>
1262
1288
 
1263
- https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_result.rb
1289
+ https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/use_case/failure_results.rb
1264
1290
 
1265
1291
  ---
1266
1292
 
1267
- ### `Micro::Cases::Flow` (v3.0.0)
1293
+ ### `Micro::Cases::Flow`
1268
1294
 
1269
- | Gems / Abstraction | [Success results](https://github.com/serradura/u-case/blob/main/benchmarks/flow/with_success_result.rb#L40) | [Failure results](https://github.com/serradura/u-case/blob/main/benchmarks/flow/with_failure_result.rb#L40) |
1295
+ | Gems / Abstraction | [Success results](https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/flow/success_results.rb) | [Failure results](https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/flow/failure_results.rb) |
1270
1296
  | ------------------------------------------- | ----------------: | ----------------: |
1271
- | Micro::Case internal flow (private methods) | _**The Fastest**_ | _**The Fastest**_ |
1272
- | Micro::Case internal flow (through lambdas) | 1.03x slower | 1.04x slower |
1273
- | Micro::Case `then` method | 1.49x slower | 0x slower |
1274
- | Micro::Cases.flow | 1.53x slower | 1.04x slower |
1275
- | Micro::Cases.safe_flow | 1.54x slower | 1.04x slower |
1276
- | Interactor::Organizer | 2.05x slower | 6.27x slower |
1297
+ | Micro::Case::Result `pipe` method | 80936.2 i/s | 78280.4 i/s |
1298
+ | Micro::Case::Result `then` method | 0x slower | 0x slower |
1299
+ | Micro::Cases.flow | 0x slower | 0x slower |
1300
+ | Micro::Case class with an inner flow | 1.72x slower | 1.68x slower |
1301
+ | Micro::Case class including itself as a step| 1.93x slower | 1.87x slower |
1302
+ | Interactor::Organizer | 3.33x slower | 3.22x slower |
1277
1303
 
1278
1304
  \* The `Dry::Monads`, `Dry::Transaction`, `Trailblazer::Operation` gems are out of this analysis because all of them doesn't have this kind of feature.
1279
1305
 
@@ -1282,40 +1308,28 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_r
1282
1308
 
1283
1309
  ```ruby
1284
1310
  # Warming up --------------------------------------
1285
- # Interactor::Organizer
1286
- # 4.837k i/100ms
1287
- # Micro::Cases.flow([])
1288
- # 6.755k i/100ms
1289
- # Micro::Cases::safe_flow([])
1290
- # 6.809k i/100ms
1291
- # Micro::Case flow using `then` method
1292
- # 6.968k i/100ms
1293
- # Micro::Case flow using private methods
1294
- # 10.362k i/100ms
1295
- # Micro::Case flow using private methods through lambdas
1296
- # 10.258k i/100ms
1311
+ # Interactor::Organizer 1.809k i/100ms
1312
+ # Micro::Cases.flow([]) 7.808k i/100ms
1313
+ # Micro::Case flow in a class 4.816k i/100ms
1314
+ # Micro::Case including the class 4.094k i/100ms
1315
+ # Micro::Case::Result#| 7.656k i/100ms
1316
+ # Micro::Case::Result#then 7.138k i/100ms
1297
1317
 
1298
1318
  # Calculating -------------------------------------
1299
- # Interactor::Organizer
1300
- # 50.731k 1.6%) i/s - 256.361k in 5.054694s
1301
- # Micro::Cases.flow([])
1302
- # 67.757k1.6%) i/s - 344.505k in 5.085681s
1303
- # Micro::Cases::safe_flow([])
1304
- # 67.613k1.6%) i/s - 340.450k in 5.036562s
1305
- # Micro::Case flow using `then` method
1306
- # 69.483k (± 1.5%) i/s - 348.400k in 5.015351s
1307
- # Micro::Case flow using private methods
1308
- # 103.788k (± 1.0%) i/s - 528.462k in 5.092240s
1309
- # Micro::Case flow using private methods through lambdas
1310
- # 101.081k (± 1.2%) i/s - 512.900k in 5.074904s
1319
+ # Interactor::Organizer 24.290k (±24.0%) i/s - 113.967k in 5.032825s
1320
+ # Micro::Cases.flow([]) 74.790k11.1%) i/s - 374.784k in 5.071740s
1321
+ # Micro::Case flow in a class 47.043k (± 8.0%) i/s - 235.984k in 5.047477s
1322
+ # Micro::Case including the class 42.030k8.5%) i/s - 208.794k in 5.002138s
1323
+ # Micro::Case::Result#| 80.936k (±15.9%) i/s - 398.112k in 5.052531s
1324
+ # Micro::Case::Result#then 71.459k8.8%) i/s - 356.900k in 5.030526s
1311
1325
 
1312
1326
  # Comparison:
1313
- # Micro::Case flow using private methods: 103787.5 i/s
1314
- # Micro::Case flow using private methods through lambdas: 101080.6 i/s - 1.03x (± 0.00) slower
1315
- # Micro::Case flow using `then` method: 69483.3 i/s - 1.49x (± 0.00) slower
1316
- # Micro::Cases.flow([]): 67757.2 i/s - 1.53x (± 0.00) slower
1317
- # Micro::Cases::safe_flow([]): 67613.3 i/s - 1.54x (± 0.00) slower
1318
- # Interactor::Organizer: 50730.8 i/s - 2.05x (± 0.00) slower
1327
+ # Micro::Case::Result#|: 80936.2 i/s
1328
+ # Micro::Cases.flow([]): 74790.1 i/s - same-ish: difference falls within error
1329
+ # Micro::Case::Result#then: 71459.5 i/s - same-ish: difference falls within error
1330
+ # Micro::Case flow in a class: 47042.6 i/s - 1.72x (± 0.00) slower
1331
+ # Micro::Case including the class: 42030.2 i/s - 1.93x (± 0.00) slower
1332
+ # Interactor::Organizer: 24290.3 i/s - 3.33x (± 0.00) slower
1319
1333
  ```
1320
1334
  </details>
1321
1335
 
@@ -1324,43 +1338,72 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_r
1324
1338
 
1325
1339
  ```ruby
1326
1340
  # Warming up --------------------------------------
1327
- # Interactor::Organizer
1328
- # 2.299k i/100ms
1329
- # Micro::Cases.flow([])
1330
- # 14.187k i/100ms
1331
- # Micro::Cases::safe_flow([])
1332
- # 13.609k i/100ms
1333
- # Micro::Case flow using `then` method
1334
- # 14.578k i/100ms
1335
- # Micro::Case flow using private methods
1336
- # 14.101k i/100ms
1337
- # Micro::Case flow using private methods through lambdas
1338
- # 13.670k i/100ms
1341
+ # Interactor::Organizer 1.734k i/100ms
1342
+ # Micro::Cases.flow([]) 7.515k i/100ms
1343
+ # Micro::Case flow in a class 4.636k i/100ms
1344
+ # Micro::Case including the class 4.114k i/100ms
1345
+ # Micro::Case::Result#| 7.588k i/100ms
1346
+ # Micro::Case::Result#then 6.681k i/100ms
1347
+
1339
1348
  # Calculating -------------------------------------
1340
- # Interactor::Organizer
1341
- # 23.306k2.1%) i/s - 117.249k in 5.033171s
1342
- # Micro::Cases.flow([])
1343
- # 140.111k1.6%) i/s - 709.350k in 5.064041s
1344
- # Micro::Cases::safe_flow([])
1345
- # 139.927k1.7%) i/s - 707.668k in 5.058971s
1346
- # Micro::Case flow using `then` method
1347
- # 146.073k (± 2.0%) i/s - 743.478k in 5.091741s
1348
- # Micro::Case flow using private methods
1349
- # 142.092k (± 1.5%) i/s - 719.151k in 5.062298s
1350
- # Micro::Case flow using private methods through lambdas
1351
- # 140.791k (± 1.2%) i/s - 710.840k in 5.049584s
1349
+ # Interactor::Organizer 24.280k (±24.5%) i/s - 112.710k in 5.013334s
1350
+ # Micro::Cases.flow([]) 74.999k9.8%) i/s - 375.750k in 5.055777s
1351
+ # Micro::Case flow in a class 46.681k (± 9.3%) i/s - 236.436k in 5.105105s
1352
+ # Micro::Case including the class 41.921k8.9%) i/s - 209.814k in 5.043622s
1353
+ # Micro::Case::Result#| 78.280k (±12.6%) i/s - 386.988k in 5.022146s
1354
+ # Micro::Case::Result#then 68.898k8.8%) i/s - 347.412k in 5.080116s
1352
1355
 
1353
1356
  # Comparison:
1354
- # Micro::Case flow using `then` method: 146073.0 i/s
1355
- # Micro::Case flow using private methods: 142091.7 i/s - same-ish: difference falls within error
1356
- # Micro::Case flow using private methods through lambdas: 140791.1 i/s - 1.04x (± 0.00) slower
1357
- # Micro::Cases.flow([]): 140110.8 i/s - 1.04x (± 0.00) slower
1358
- # Micro::Cases::safe_flow([]): 139926.6 i/s - 1.04x (± 0.00) slower
1359
- # Interactor::Organizer: 23305.9 i/s - 6.27x (± 0.00) slower
1357
+ # Micro::Case::Result#|: 78280.4 i/s
1358
+ # Micro::Cases.flow([]): 74999.4 i/s - same-ish: difference falls within error
1359
+ # Micro::Case::Result#then: 68898.4 i/s - same-ish: difference falls within error
1360
+ # Micro::Case flow in a class: 46681.0 i/s - 1.68x (± 0.00) slower
1361
+ # Micro::Case including the class: 41920.8 i/s - 1.87x (± 0.00) slower
1362
+ # Interactor::Organizer: 24280.0 i/s - 3.22x (± 0.00) slower
1360
1363
  ```
1361
1364
  </details>
1362
1365
 
1363
- https://github.com/serradura/u-case/tree/main/benchmarks/flow
1366
+ https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/flow/
1367
+
1368
+ [⬆️ Back to Top](#table-of-contents-)
1369
+
1370
+ ### Running the benchmarks
1371
+
1372
+ #### Performance (Benchmarks IPS)
1373
+
1374
+ Clone this repo and access its folder, then run the commands below:
1375
+
1376
+ **Use cases**
1377
+
1378
+ ```sh
1379
+ ruby benchmarks/perfomance/use_case/failure_results.rb
1380
+ ruby benchmarks/perfomance/use_case/success_results.rb
1381
+ ```
1382
+
1383
+ **Flows**
1384
+
1385
+ ```sh
1386
+ ruby benchmarks/perfomance/flow/failure_results.rb
1387
+ ruby benchmarks/perfomance/flow/success_results.rb
1388
+ ```
1389
+
1390
+ #### Memory profiling
1391
+
1392
+ **Use cases**
1393
+
1394
+ ```sh
1395
+ ./benchmarks/memory/use_case/success/with_transitions/analyze.sh
1396
+ ./benchmarks/memory/use_case/success/without_transitions/analyze.sh
1397
+ ```
1398
+
1399
+ **Flows**
1400
+
1401
+ ```sh
1402
+ ./benchmarks/memory/flow/success/with_transitions/analyze.sh
1403
+ ./benchmarks/memory/flow/success/without_transitions/analyze.sh
1404
+ ```
1405
+
1406
+ [⬆️ Back to Top](#table-of-contents-)
1364
1407
 
1365
1408
  ### Comparisons
1366
1409