u-case 3.1.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3472991bd5b3d6198cb7455044ac8144445b61c860ce76ca191eba1f6e09aac
4
- data.tar.gz: eebefecaa4a27d98f3a558aa17a1731de6639a69cc5011fc6acdf430a7e1f52b
3
+ metadata.gz: e5a9b11b39c8c90670c4308c91e4e887871eb8f98a1fb739c4be71885a14d0b8
4
+ data.tar.gz: d4ce16229a9afd7dd4d1a1cf8e5b11067a11a6317c6857264ba46b324b220994
5
5
  SHA512:
6
- metadata.gz: e8cc6cc9994b30bc71b3a5485123dcd41a5583c195bba9969da41e85efb6ebb964f4ee5e39d02f86e324a2cbea24b420f1a9fa67d1dca410c8a60539873d80b9
7
- data.tar.gz: 48b7f05a0473dba7885d1907d794b503c44030de29b53e0fd757f71597e37c8d0248db980b071ae8f2492e207bfddb0616b25dd9acbefd219318114f72b73339
6
+ metadata.gz: '078f264aa7ca294bcbc12e97b4ef210a11a46151adc94d7954846e81f6e6f1647896969ee8fcf40b1bf715145b7adf029f7d22d26f226c7071d29ea477ca56b7'
7
+ data.tar.gz: e5a24e5095cb1178e92919d3f953bfbc6d690242dffafb9b8cdc4ce7c00e943c9921d4013e76b3e062d4269d32b4e4f7bb133951cc0e395416090b36cbf91b36
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <p align="center">
2
- <img src="./assets/ucase_logo_v1.png" alt="u-case - Create simple and powerful use cases as Ruby objects.">
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.">
3
3
 
4
- <p align="center"><i>Create simple and powerful use cases as Ruby objects.</i></p>
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
5
  <br>
6
6
  </p>
7
7
 
@@ -38,7 +38,8 @@ The main project goals are:
38
38
 
39
39
  Version | Documentation
40
40
  --------- | -------------
41
- 3.1.0 | https://github.com/serradura/u-case/blob/main/README.md
41
+ 4.0.0 | https://github.com/serradura/u-case/blob/main/README.md
42
+ 3.1.0 | https://github.com/serradura/u-case/blob/v3.x/README.md
42
43
  2.6.0 | https://github.com/serradura/u-case/blob/v2.x/README.md
43
44
  1.1.0 | https://github.com/serradura/u-case/blob/v1.x/README.md
44
45
 
@@ -81,6 +82,9 @@ Version | Documentation
81
82
  - [Success results](#success-results)
82
83
  - [Failure results](#failure-results)
83
84
  - [`Micro::Cases::Flow`](#microcasesflow)
85
+ - [Running the benchmarks](#running-the-benchmarks)
86
+ - [Performance (Benchmarks IPS)](#performance-benchmarks-ips)
87
+ - [Memory profiling](#memory-profiling)
84
88
  - [Comparisons](#comparisons)
85
89
  - [Examples](#examples)
86
90
  - [1️⃣ Users creation](#1️⃣-users-creation)
@@ -94,11 +98,12 @@ Version | Documentation
94
98
 
95
99
  ## Compatibility
96
100
 
97
- | u-case | branch | ruby | activemodel |
98
- | -------------- | ------- | -------- | ------------- |
99
- | 3.1.0 | main | >= 2.2.0 | >= 3.2, < 6.1 |
100
- | 2.6.0 | v2.x | >= 2.2.0 | >= 3.2, < 6.1 |
101
- | 1.1.0 | v1.x | >= 2.2.0 | >= 3.2, < 6.1 |
101
+ | u-case | branch | ruby | activemodel | u-attributes |
102
+ | -------------- | ------- | -------- | ------------- | ------------ |
103
+ | 4.0.0 | main | >= 2.2.0 | >= 3.2, < 6.1 | ~> 2.0 |
104
+ | 3.1.0 | v3.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
105
+ | 2.6.0 | v2.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
106
+ | 1.1.0 | v1.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
102
107
 
103
108
  > 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.
104
109
 
@@ -128,7 +133,7 @@ And then execute:
128
133
 
129
134
  Or install it yourself as:
130
135
 
131
- $ gem install u-case --pre
136
+ $ gem install u-case
132
137
 
133
138
  ## Usage
134
139
 
@@ -1193,104 +1198,104 @@ end
1193
1198
 
1194
1199
  | Gem / Abstraction | Iterations per second | Comparison |
1195
1200
  | ----------------- | --------------------: | ----------------: |
1196
- | Dry::Monads | 141730.1 | _**The Fastest**_ |
1197
- | **Micro::Case** | 103541.3 | 1.37x slower |
1198
- | Interactor | 29100.8 | 4.87x slower |
1199
- | Trailblazer::Operation | 15031.4 | 9.43x slower |
1200
- | Dry::Transaction | 5674.0 | 24.98x slower |
1201
+ | Dry::Monads | 281515.4 | _**The Fastest**_ |
1202
+ | **Micro::Case** | 151711.3 | 1.86x slower |
1203
+ | Interactor | 53016.2 | 5.31x slower |
1204
+ | Trailblazer::Operation | 38314.2 | 7.35x slower |
1205
+ | Dry::Transaction | 10440.7 | 26.96x slower |
1201
1206
 
1202
1207
  <details>
1203
1208
  <summary>Show the full <a href="https://github.com/evanphx/benchmark-ips">benchmark/ips</a> results.</summary>
1204
1209
 
1205
1210
  ```ruby
1206
1211
  # Warming up --------------------------------------
1207
- # Interactor 2.915k i/100ms
1208
- # Trailblazer::Operation 1.543k i/100ms
1209
- # Dry::Monads 14.288k i/100ms
1210
- # Dry::Transaction 571.000 i/100ms
1211
- # Micro::Case 10.418k i/100ms
1212
- # Micro::Case::Strict 8.296k i/100ms
1213
- # Micro::Case::Safe 10.254k i/100ms
1212
+ # Interactor 5.151k i/100ms
1213
+ # Trailblazer::Operation 3.805k i/100ms
1214
+ # Dry::Monads 28.153k i/100ms
1215
+ # Dry::Transaction 1.063k i/100ms
1216
+ # Micro::Case 15.159k i/100ms
1217
+ # Micro::Case::Safe 15.172k i/100ms
1218
+ # Micro::Case::Strict 12.557k i/100ms
1214
1219
 
1215
1220
  # Calculating -------------------------------------
1216
- # Interactor 29.101k2.1%) i/s - 145.750k in 5.010660s
1217
- # Trailblazer::Operation 15.031k2.0%) i/s - 75.607k in 5.032071s
1218
- # Dry::Monads 141.730k3.1%) i/s - 714.400k in 5.045546s
1219
- # Dry::Transaction 5.674k (± 1.9%) i/s - 28.550k in 5.033564s
1220
- # Micro::Case 103.541k (± 1.6%) i/s - 520.900k in 5.032077s
1221
- # Micro::Case::Strict 83.045k2.4%) i/s - 423.096k in 5.098031s
1222
- # Micro::Case::Safe 101.662k1.5%) i/s - 512.700k in 5.044386s
1221
+ # Interactor 53.016k1.8%) i/s - 267.852k in 5.053967s
1222
+ # Trailblazer::Operation 38.314k1.7%) i/s - 194.055k in 5.066374s
1223
+ # Dry::Monads 281.515k2.4%) i/s - 1.408M in 5.003266s
1224
+ # Dry::Transaction 10.441k2.1%) i/s - 53.150k in 5.092957s
1225
+ # Micro::Case 151.711k (± 1.7%) i/s - 773.109k in 5.097555s
1226
+ # Micro::Case::Safe 145.801k6.7%) i/s - 728.256k in 5.022666s
1227
+ # Micro::Case::Strict 115.636k8.4%) i/s - 577.622k in 5.042079s
1223
1228
 
1224
1229
  # Comparison:
1225
- # Dry::Monads: 141730.1 i/s
1226
- # Micro::Case: 103541.3 i/s - 1.37x (± 0.00) slower
1227
- # Micro::Case::Safe: 101662.2 i/s - 1.39x (± 0.00) slower
1228
- # Micro::Case::Strict: 83044.6 i/s - 1.71x (± 0.00) slower
1229
- # Interactor: 29100.8 i/s - 4.87x (± 0.00) slower
1230
- # Trailblazer::Operation: 15031.4 i/s - 9.43x (± 0.00) slower
1231
- # Dry::Transaction: 5674.0 i/s - 24.98x (± 0.00) slower
1230
+ # Dry::Monads: 281515.4 i/s
1231
+ # Micro::Case: 151711.3 i/s - 1.86x (± 0.00) slower
1232
+ # Micro::Case::Safe: 145800.8 i/s - 1.93x (± 0.00) slower
1233
+ # Micro::Case::Strict: 115635.8 i/s - 2.43x (± 0.00) slower
1234
+ # Interactor: 53016.2 i/s - 5.31x (± 0.00) slower
1235
+ # Trailblazer::Operation: 38314.2 i/s - 7.35x (± 0.00) slower
1236
+ # Dry::Transaction: 10440.7 i/s - 26.96x (± 0.00) slower
1232
1237
  ```
1233
1238
  </details>
1234
1239
 
1235
- https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_success_result.rb
1240
+ https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/use_case/success_results.rb
1236
1241
 
1237
1242
  #### Failure results
1238
1243
 
1239
1244
  | Gem / Abstraction | Iterations per second | Comparison |
1240
1245
  | ----------------- | --------------------: | ----------------: |
1241
- | **Micro::Case** | 98820.8 | _**The Fastest**_ |
1242
- | Dry::Monads | 71329.7 | 1.39x slower |
1243
- | Trailblazer::Operation | 15034.9 | 6.57x slower |
1244
- | Interactor | 13958.7 | 7.08x slower |
1245
- | Dry::Transaction | 5067.5 | 19.50x slower |
1246
+ | **Micro::Case** | 140794.0 | _**The Fastest**_ |
1247
+ | Dry::Monads | 133865.5 | 0x slower |
1248
+ | Trailblazer::Operation | 39829.9 | 3.53x slower |
1249
+ | Interactor | 23856.0 | 5.90x slower |
1250
+ | Dry::Transaction | 7975.0 | 17.65x slower |
1246
1251
 
1247
1252
  <details>
1248
1253
  <summary>Show the full <a href="https://github.com/evanphx/benchmark-ips">benchmark/ips</a> results.</summary>
1249
1254
 
1250
1255
  ```ruby
1251
1256
  # Warming up --------------------------------------
1252
- # Interactor 1.324k i/100ms
1253
- # Trailblazer::Operation 1.525k i/100ms
1254
- # Dry::Monads 7.126k i/100ms
1255
- # Dry::Transaction 499.000 i/100ms
1256
- # Micro::Case 9.919k i/100ms
1257
- # Micro::Case::Strict 7.837k i/100ms
1258
- # Micro::Case::Safe 9.762k i/100ms
1257
+ # Interactor 2.351k i/100ms
1258
+ # Trailblazer::Operation 3.941k i/100ms
1259
+ # Dry::Monads 13.567k i/100ms
1260
+ # Dry::Transaction 927.000 i/100ms
1261
+ # Micro::Case 14.959k i/100ms
1262
+ # Micro::Case::Safe 14.904k i/100ms
1263
+ # Micro::Case::Strict 12.007k i/100ms
1259
1264
 
1260
1265
  # Calculating -------------------------------------
1261
- # Interactor 13.959k2.5%) i/s - 70.172k in 5.030240s
1262
- # Trailblazer::Operation 15.035k2.2%) i/s - 76.250k in 5.074108s
1263
- # Dry::Monads 71.330k (± 2.4%) i/s - 363.426k in 5.097993s
1264
- # Dry::Transaction 5.068k1.9%) i/s - 25.449k in 5.023922s
1265
- # Micro::Case 98.821k 2.9%) i/s - 495.950k in 5.023421s
1266
- # Micro::Case::Strict 79.936k3.1%) i/s - 399.687k in 5.005435s
1267
- # Micro::Case::Safe 98.695k 1.9%) i/s - 497.862k in 5.046246s
1266
+ # Interactor 23.856k1.7%) i/s - 119.901k in 5.027585s
1267
+ # Trailblazer::Operation 39.830k1.2%) i/s - 200.991k in 5.047032s
1268
+ # Dry::Monads 133.866k (± 2.5%) i/s - 678.350k in 5.070899s
1269
+ # Dry::Transaction 7.975k8.6%) i/s - 39.861k in 5.036260s
1270
+ # Micro::Case 130.534k24.4%) i/s - 583.401k in 5.040907s
1271
+ # Micro::Case::Safe 140.794k8.1%) i/s - 700.488k in 5.020935s
1272
+ # Micro::Case::Strict 102.641k21.3%) i/s - 480.280k in 5.020354s
1268
1273
 
1269
1274
  # Comparison:
1270
- # Micro::Case: 98820.8 i/s
1271
- # Micro::Case::Safe: 98695.0 i/s - same-ish: difference falls within error
1272
- # Micro::Case::Strict: 79935.9 i/s - 1.24x (± 0.00) slower
1273
- # Dry::Monads: 71329.7 i/s - 1.39x (± 0.00) slower
1274
- # Trailblazer::Operation: 15034.9 i/s - 6.57x (± 0.00) slower
1275
- # Interactor: 13958.7 i/s - 7.08x (± 0.00) slower
1276
- # Dry::Transaction: 5067.5 i/s - 19.50x (± 0.00) slower
1275
+ # Micro::Case::Safe: 140794.0 i/s
1276
+ # Dry::Monads: 133865.5 i/s - same-ish: difference falls within error
1277
+ # Micro::Case: 130534.0 i/s - same-ish: difference falls within error
1278
+ # Micro::Case::Strict: 102640.7 i/s - 1.37x (± 0.00) slower
1279
+ # Trailblazer::Operation: 39829.9 i/s - 3.53x (± 0.00) slower
1280
+ # Interactor: 23856.0 i/s - 5.90x (± 0.00) slower
1281
+ # Dry::Transaction: 7975.0 i/s - 17.65x (± 0.00) slower
1277
1282
  ```
1278
1283
  </details>
1279
1284
 
1280
- https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_result.rb
1285
+ https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/use_case/failure_results.rb
1281
1286
 
1282
1287
  ---
1283
1288
 
1284
1289
  ### `Micro::Cases::Flow`
1285
1290
 
1286
- | 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) |
1291
+ | 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) |
1287
1292
  | ------------------------------------------- | ----------------: | ----------------: |
1288
- | Micro::Case internal flow (private methods) | _**The Fastest**_ | _**The Fastest**_ |
1289
- | Micro::Case internal flow (through lambdas) | 1.03x slower | 1.04x slower |
1290
- | Micro::Case `then` method | 1.49x slower | 0x slower |
1291
- | Micro::Cases.flow | 1.53x slower | 1.04x slower |
1292
- | Micro::Cases.safe_flow | 1.54x slower | 1.04x slower |
1293
- | Interactor::Organizer | 2.05x slower | 6.27x slower |
1293
+ | Micro::Case::Result `pipe` method | 172734.4 i/s | 153745.6 i/s |
1294
+ | Micro::Case::Result `then` method | 1.24x slower | 1.21x slower |
1295
+ | Micro::Cases.flow | 1.30x slower | 1.30x slower |
1296
+ | Micro::Case class with an inner flow | 2.05x slower | 1.98x slower |
1297
+ | Micro::Case class including itself as a step| 2.14x slower | 2.09x slower |
1298
+ | Interactor::Organizer | 7.69x slower | 7.03x slower |
1294
1299
 
1295
1300
  \* The `Dry::Monads`, `Dry::Transaction`, `Trailblazer::Operation` gems are out of this analysis because all of them doesn't have this kind of feature.
1296
1301
 
@@ -1299,40 +1304,28 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_r
1299
1304
 
1300
1305
  ```ruby
1301
1306
  # Warming up --------------------------------------
1302
- # Interactor::Organizer
1303
- # 4.837k i/100ms
1304
- # Micro::Cases.flow([])
1305
- # 6.755k i/100ms
1306
- # Micro::Cases::safe_flow([])
1307
- # 6.809k i/100ms
1308
- # Micro::Case flow using `then` method
1309
- # 6.968k i/100ms
1310
- # Micro::Case flow using private methods
1311
- # 10.362k i/100ms
1312
- # Micro::Case flow using private methods through lambdas
1313
- # 10.258k i/100ms
1307
+ # Interactor::Organizer 2.163k i/100ms
1308
+ # Micro::Cases.flow([]) 13.158k i/100ms
1309
+ # Micro::Case flow in a class 8.400k i/100ms
1310
+ # Micro::Case including the class 8.008k i/100ms
1311
+ # Micro::Case::Result#| 17.151k i/100ms
1312
+ # Micro::Case::Result#then 14.121k i/100ms
1314
1313
 
1315
1314
  # Calculating -------------------------------------
1316
- # Interactor::Organizer
1317
- # 50.731k (± 1.6%) i/s - 256.361k in 5.054694s
1318
- # Micro::Cases.flow([])
1319
- # 67.757k (± 1.6%) i/s - 344.505k in 5.085681s
1320
- # Micro::Cases::safe_flow([])
1321
- # 67.613k (± 1.6%) i/s - 340.450k in 5.036562s
1322
- # Micro::Case flow using `then` method
1323
- # 69.483k (± 1.5%) i/s - 348.400k in 5.015351s
1324
- # Micro::Case flow using private methods
1325
- # 103.788k (± 1.0%) i/s - 528.462k in 5.092240s
1326
- # Micro::Case flow using private methods through lambdas
1327
- # 101.081k (± 1.2%) i/s - 512.900k in 5.074904s
1315
+ # Interactor::Organizer 22.467k (± 1.8%) i/s - 112.476k in 5.007787s
1316
+ # Micro::Cases.flow([]) 133.183k (± 1.5%) i/s - 671.058k in 5.039815s
1317
+ # Micro::Case flow in a class 84.083k (± 1.8%) i/s - 428.400k in 5.096623s
1318
+ # Micro::Case including the class 80.574k (± 1.6%) i/s - 408.408k in 5.070029s
1319
+ # Micro::Case::Result#| 172.734k (± 1.1%) i/s - 874.701k in 5.064429s
1320
+ # Micro::Case::Result#then 139.799k (± 1.7%) i/s - 706.050k in 5.052035s
1328
1321
 
1329
1322
  # Comparison:
1330
- # Micro::Case flow using private methods: 103787.5 i/s
1331
- # Micro::Case flow using private methods through lambdas: 101080.6 i/s - 1.03x (± 0.00) slower
1332
- # Micro::Case flow using `then` method: 69483.3 i/s - 1.49x (± 0.00) slower
1333
- # Micro::Cases.flow([]): 67757.2 i/s - 1.53x (± 0.00) slower
1334
- # Micro::Cases::safe_flow([]): 67613.3 i/s - 1.54x (± 0.00) slower
1335
- # Interactor::Organizer: 50730.8 i/s - 2.05x (± 0.00) slower
1323
+ # Micro::Case::Result#|: 172734.4 i/s
1324
+ # Micro::Case::Result#then: 139799.0 i/s - 1.24x (± 0.00) slower
1325
+ # Micro::Cases.flow([]): 133182.9 i/s - 1.30x (± 0.00) slower
1326
+ # Micro::Case flow in a class: 84082.6 i/s - 2.05x (± 0.00) slower
1327
+ # Micro::Case including the class: 80574.3 i/s - 2.14x (± 0.00) slower
1328
+ # Interactor::Organizer: 22467.4 i/s - 7.69x (± 0.00) slower
1336
1329
  ```
1337
1330
  </details>
1338
1331
 
@@ -1341,43 +1334,72 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_r
1341
1334
 
1342
1335
  ```ruby
1343
1336
  # Warming up --------------------------------------
1344
- # Interactor::Organizer
1345
- # 2.299k i/100ms
1346
- # Micro::Cases.flow([])
1347
- # 14.187k i/100ms
1348
- # Micro::Cases::safe_flow([])
1349
- # 13.609k i/100ms
1350
- # Micro::Case flow using `then` method
1351
- # 14.578k i/100ms
1352
- # Micro::Case flow using private methods
1353
- # 14.101k i/100ms
1354
- # Micro::Case flow using private methods through lambdas
1355
- # 13.670k i/100ms
1337
+ # Interactor::Organizer 2.167k i/100ms
1338
+ # Micro::Cases.flow([]) 11.797k i/100ms
1339
+ # Micro::Case flow in a class 7.783k i/100ms
1340
+ # Micro::Case including the class 7.097k i/100ms
1341
+ # Micro::Case::Result#| 14.398k i/100ms
1342
+ # Micro::Case::Result#then 12.719k i/100ms
1343
+
1356
1344
  # Calculating -------------------------------------
1357
- # Interactor::Organizer
1358
- # 23.306k2.1%) i/s - 117.249k in 5.033171s
1359
- # Micro::Cases.flow([])
1360
- # 140.111k (± 1.6%) i/s - 709.350k in 5.064041s
1361
- # Micro::Cases::safe_flow([])
1362
- # 139.927k (± 1.7%) i/s - 707.668k in 5.058971s
1363
- # Micro::Case flow using `then` method
1364
- # 146.073k (± 2.0%) i/s - 743.478k in 5.091741s
1365
- # Micro::Case flow using private methods
1366
- # 142.092k (± 1.5%) i/s - 719.151k in 5.062298s
1367
- # Micro::Case flow using private methods through lambdas
1368
- # 140.791k (± 1.2%) i/s - 710.840k in 5.049584s
1345
+ # Interactor::Organizer 21.863k (± 2.5%) i/s - 110.517k in 5.058420s
1346
+ # Micro::Cases.flow([]) 118.124k1.8%) i/s - 601.647k in 5.095102s
1347
+ # Micro::Case flow in a class 77.801k (± 1.5%) i/s - 389.150k in 5.003002s
1348
+ # Micro::Case including the class 73.533k2.1%) i/s - 369.044k in 5.021076s
1349
+ # Micro::Case::Result#| 153.746k (± 1.5%) i/s - 777.492k in 5.058177s
1350
+ # Micro::Case::Result#then 126.897k (± 1.7%) i/s - 635.950k in 5.013059s
1369
1351
 
1370
1352
  # Comparison:
1371
- # Micro::Case flow using `then` method: 146073.0 i/s
1372
- # Micro::Case flow using private methods: 142091.7 i/s - same-ish: difference falls within error
1373
- # Micro::Case flow using private methods through lambdas: 140791.1 i/s - 1.04x (± 0.00) slower
1374
- # Micro::Cases.flow([]): 140110.8 i/s - 1.04x (± 0.00) slower
1375
- # Micro::Cases::safe_flow([]): 139926.6 i/s - 1.04x (± 0.00) slower
1376
- # Interactor::Organizer: 23305.9 i/s - 6.27x (± 0.00) slower
1353
+ # Micro::Case::Result#|: 153745.6 i/s
1354
+ # Micro::Case::Result#then: 126896.6 i/s - 1.21x (± 0.00) slower
1355
+ # Micro::Cases.flow([]): 118123.9 i/s - 1.30x (± 0.00) slower
1356
+ # Micro::Case flow in a class: 77800.7 i/s - 1.98x (± 0.00) slower
1357
+ # Micro::Case including the class: 73532.9 i/s - 2.09x (± 0.00) slower
1358
+ # Interactor::Organizer: 21862.9 i/s - 7.03x (± 0.00) slower
1377
1359
  ```
1378
1360
  </details>
1379
1361
 
1380
- https://github.com/serradura/u-case/tree/main/benchmarks/flow
1362
+ https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/flow/
1363
+
1364
+ [⬆️ Back to Top](#table-of-contents-)
1365
+
1366
+ ### Running the benchmarks
1367
+
1368
+ #### Performance (Benchmarks IPS)
1369
+
1370
+ Clone this repo and access its folder, then run the commands below:
1371
+
1372
+ **Use cases**
1373
+
1374
+ ```sh
1375
+ ruby benchmarks/perfomance/use_case/failure_results.rb
1376
+ ruby benchmarks/perfomance/use_case/success_results.rb
1377
+ ```
1378
+
1379
+ **Flows**
1380
+
1381
+ ```sh
1382
+ ruby benchmarks/perfomance/flow/failure_results.rb
1383
+ ruby benchmarks/perfomance/flow/success_results.rb
1384
+ ```
1385
+
1386
+ #### Memory profiling
1387
+
1388
+ **Use cases**
1389
+
1390
+ ```sh
1391
+ ./benchmarks/memory/use_case/success/with_transitions/analyze.sh
1392
+ ./benchmarks/memory/use_case/success/without_transitions/analyze.sh
1393
+ ```
1394
+
1395
+ **Flows**
1396
+
1397
+ ```sh
1398
+ ./benchmarks/memory/flow/success/with_transitions/analyze.sh
1399
+ ./benchmarks/memory/flow/success/without_transitions/analyze.sh
1400
+ ```
1401
+
1402
+ [⬆️ Back to Top](#table-of-contents-)
1381
1403
 
1382
1404
  ### Comparisons
1383
1405
 
@@ -1,7 +1,7 @@
1
1
  <p align="center">
2
- <img src="./assets/ucase_logo_v1.png" alt="u-case - Create simple and powerful use cases as Ruby objects.">
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.">
3
3
 
4
- <p align="center"><i>Crie simples e poderosos casos de uso como objetos em Ruby.</i></p>
4
+ <p align="center"><i> Represente casos de uso de forma simples e poderosa ao escrever código modular, expressivo e sequencialmente lógico.</i></p>
5
5
  <br>
6
6
  </p>
7
7
 
@@ -38,7 +38,8 @@ Principais objetivos deste projeto:
38
38
 
39
39
  Versão | Documentação
40
40
  --------- | -------------
41
- 3.1.0 | https://github.com/serradura/u-case/blob/main/README.md
41
+ 4.0.0 | https://github.com/serradura/u-case/blob/main/README.md
42
+ 3.1.0 | https://github.com/serradura/u-case/blob/v3.x/README.md
42
43
  2.6.0 | https://github.com/serradura/u-case/blob/v2.x/README.md
43
44
  1.1.0 | https://github.com/serradura/u-case/blob/v1.x/README.md
44
45
 
@@ -80,6 +81,9 @@ Versão | Documentação
80
81
  - [Success results](#success-results)
81
82
  - [Failure results](#failure-results)
82
83
  - [`Micro::Cases::Flow`](#microcasesflow)
84
+ - [Execuntando os benchmarks](#execuntando-os-benchmarks)
85
+ - [Performance (Benchmarks IPS)](#performance-benchmarks-ips)
86
+ - [Memory profiling](#memory-profiling)
83
87
  - [Comparações](#comparações)
84
88
  - [Exemplos](#exemplos)
85
89
  - [1️⃣ Criação de usuários](#1️⃣-criação-de-usuários)
@@ -93,11 +97,12 @@ Versão | Documentação
93
97
 
94
98
  ## Compatibilidade
95
99
 
96
- | u-case | branch | ruby | activemodel |
97
- | -------------- | ------- | -------- | ------------- |
98
- | 3.1.0 | main | >= 2.2.0 | >= 3.2, < 6.1 |
99
- | 2.6.0 | v2.x | >= 2.2.0 | >= 3.2, < 6.1 |
100
- | 1.1.0 | v1.x | >= 2.2.0 | >= 3.2, < 6.1 |
100
+ | u-case | branch | ruby | activemodel | u-attributes |
101
+ | -------------- | ------- | -------- | ------------- | ------------ |
102
+ | 4.0.0 | main | >= 2.2.0 | >= 3.2, < 6.1 | ~> 2.0 |
103
+ | 3.1.0 | v3.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
104
+ | 2.6.0 | v2.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
105
+ | 1.1.0 | v1.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
101
106
 
102
107
  > Nota: O activemodel é uma dependência opcional, esse módulo que [pode ser habilitado](#u-casewith_activemodel_validation---como-validar-os-atributos-do-caso-de-uso) para validar os atributos dos casos de uso.
103
108
 
@@ -127,7 +132,7 @@ E então execute:
127
132
 
128
133
  Ou instale manualmente:
129
134
 
130
- $ gem install u-case --pre
135
+ $ gem install u-case
131
136
 
132
137
  ## Uso
133
138
 
@@ -1197,104 +1202,104 @@ end
1197
1202
 
1198
1203
  | Gem / Abstração | Iterações por segundo | Comparação |
1199
1204
  | ----------------- | --------------------: | ----------------: |
1200
- | Dry::Monads | 141730.1 | _**O mais rápido**_ |
1201
- | **Micro::Case** | 103541.3 | 1.37x slower |
1202
- | Interactor | 29100.8 | 4.87x slower |
1203
- | Trailblazer::Operation | 15031.4 | 9.43x slower |
1204
- | Dry::Transaction | 5674.0 | 24.98x slower |
1205
+ | Dry::Monads | 281515.4 | _**O mais rápido**_ |
1206
+ | **Micro::Case** | 151711.3 | 1.86x mais lento |
1207
+ | Interactor | 53016.2 | 5.31x mais lento |
1208
+ | Trailblazer::Operation | 38314.2 | 7.35x mais lento |
1209
+ | Dry::Transaction | 10440.7 | 26.96x mais lento |
1205
1210
 
1206
1211
  <details>
1207
1212
  <summary>Show the full <a href="https://github.com/evanphx/benchmark-ips">benchmark/ips</a> results.</summary>
1208
1213
 
1209
1214
  ```ruby
1210
1215
  # Warming up --------------------------------------
1211
- # Interactor 2.915k i/100ms
1212
- # Trailblazer::Operation 1.543k i/100ms
1213
- # Dry::Monads 14.288k i/100ms
1214
- # Dry::Transaction 571.000 i/100ms
1215
- # Micro::Case 10.418k i/100ms
1216
- # Micro::Case::Strict 8.296k i/100ms
1217
- # Micro::Case::Safe 10.254k i/100ms
1216
+ # Interactor 5.151k i/100ms
1217
+ # Trailblazer::Operation 3.805k i/100ms
1218
+ # Dry::Monads 28.153k i/100ms
1219
+ # Dry::Transaction 1.063k i/100ms
1220
+ # Micro::Case 15.159k i/100ms
1221
+ # Micro::Case::Safe 15.172k i/100ms
1222
+ # Micro::Case::Strict 12.557k i/100ms
1218
1223
 
1219
1224
  # Calculating -------------------------------------
1220
- # Interactor 29.101k2.1%) i/s - 145.750k in 5.010660s
1221
- # Trailblazer::Operation 15.031k2.0%) i/s - 75.607k in 5.032071s
1222
- # Dry::Monads 141.730k3.1%) i/s - 714.400k in 5.045546s
1223
- # Dry::Transaction 5.674k (± 1.9%) i/s - 28.550k in 5.033564s
1224
- # Micro::Case 103.541k (± 1.6%) i/s - 520.900k in 5.032077s
1225
- # Micro::Case::Strict 83.045k2.4%) i/s - 423.096k in 5.098031s
1226
- # Micro::Case::Safe 101.662k1.5%) i/s - 512.700k in 5.044386s
1225
+ # Interactor 53.016k1.8%) i/s - 267.852k in 5.053967s
1226
+ # Trailblazer::Operation 38.314k1.7%) i/s - 194.055k in 5.066374s
1227
+ # Dry::Monads 281.515k2.4%) i/s - 1.408M in 5.003266s
1228
+ # Dry::Transaction 10.441k2.1%) i/s - 53.150k in 5.092957s
1229
+ # Micro::Case 151.711k (± 1.7%) i/s - 773.109k in 5.097555s
1230
+ # Micro::Case::Safe 145.801k6.7%) i/s - 728.256k in 5.022666s
1231
+ # Micro::Case::Strict 115.636k8.4%) i/s - 577.622k in 5.042079s
1227
1232
 
1228
1233
  # Comparison:
1229
- # Dry::Monads: 141730.1 i/s
1230
- # Micro::Case: 103541.3 i/s - 1.37x (± 0.00) slower
1231
- # Micro::Case::Safe: 101662.2 i/s - 1.39x (± 0.00) slower
1232
- # Micro::Case::Strict: 83044.6 i/s - 1.71x (± 0.00) slower
1233
- # Interactor: 29100.8 i/s - 4.87x (± 0.00) slower
1234
- # Trailblazer::Operation: 15031.4 i/s - 9.43x (± 0.00) slower
1235
- # Dry::Transaction: 5674.0 i/s - 24.98x (± 0.00) slower
1234
+ # Dry::Monads: 281515.4 i/s
1235
+ # Micro::Case: 151711.3 i/s - 1.86x (± 0.00) slower
1236
+ # Micro::Case::Safe: 145800.8 i/s - 1.93x (± 0.00) slower
1237
+ # Micro::Case::Strict: 115635.8 i/s - 2.43x (± 0.00) slower
1238
+ # Interactor: 53016.2 i/s - 5.31x (± 0.00) slower
1239
+ # Trailblazer::Operation: 38314.2 i/s - 7.35x (± 0.00) slower
1240
+ # Dry::Transaction: 10440.7 i/s - 26.96x (± 0.00) slower
1236
1241
  ```
1237
1242
  </details>
1238
1243
 
1239
- 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.
1240
1245
 
1241
1246
  #### Failure results
1242
1247
 
1243
1248
  | Gem / Abstração | Iterações por segundo | Comparação |
1244
1249
  | ----------------- | --------------------: | ----------------: |
1245
- | **Micro::Case** | 98820.8 | _**O mais rápido**_ |
1246
- | Dry::Monads | 71329.7 | 1.39x slower |
1247
- | Trailblazer::Operation | 15034.9 | 6.57x slower |
1248
- | Interactor | 13958.7 | 7.08x slower |
1249
- | Dry::Transaction | 5067.5 | 19.50x slower |
1250
+ | **Micro::Case** | 140794.0 | _**O mais rápido**_ |
1251
+ | Dry::Monads | 133865.5 | 0x mais devagar |
1252
+ | Trailblazer::Operation | 39829.9 | 3.53x mais devagar |
1253
+ | Interactor | 23856.0 | 5.90x mais devagar |
1254
+ | Dry::Transaction | 7975.0 | 17.65x mais devagar |
1250
1255
 
1251
1256
  <details>
1252
1257
  <summary>Mostrar o resultado completo do <a href="https://github.com/evanphx/benchmark-ips">benchmark/ips</a>.</summary>
1253
1258
 
1254
1259
  ```ruby
1255
1260
  # Warming up --------------------------------------
1256
- # Interactor 1.324k i/100ms
1257
- # Trailblazer::Operation 1.525k i/100ms
1258
- # Dry::Monads 7.126k i/100ms
1259
- # Dry::Transaction 499.000 i/100ms
1260
- # Micro::Case 9.919k i/100ms
1261
- # Micro::Case::Strict 7.837k i/100ms
1262
- # Micro::Case::Safe 9.762k i/100ms
1261
+ # Interactor 2.351k i/100ms
1262
+ # Trailblazer::Operation 3.941k i/100ms
1263
+ # Dry::Monads 13.567k i/100ms
1264
+ # Dry::Transaction 927.000 i/100ms
1265
+ # Micro::Case 14.959k i/100ms
1266
+ # Micro::Case::Safe 14.904k i/100ms
1267
+ # Micro::Case::Strict 12.007k i/100ms
1263
1268
 
1264
1269
  # Calculating -------------------------------------
1265
- # Interactor 13.959k2.5%) i/s - 70.172k in 5.030240s
1266
- # Trailblazer::Operation 15.035k2.2%) i/s - 76.250k in 5.074108s
1267
- # Dry::Monads 71.330k (± 2.4%) i/s - 363.426k in 5.097993s
1268
- # Dry::Transaction 5.068k1.9%) i/s - 25.449k in 5.023922s
1269
- # Micro::Case 98.821k 2.9%) i/s - 495.950k in 5.023421s
1270
- # Micro::Case::Strict 79.936k3.1%) i/s - 399.687k in 5.005435s
1271
- # Micro::Case::Safe 98.695k 1.9%) i/s - 497.862k in 5.046246s
1270
+ # Interactor 23.856k1.7%) i/s - 119.901k in 5.027585s
1271
+ # Trailblazer::Operation 39.830k1.2%) i/s - 200.991k in 5.047032s
1272
+ # Dry::Monads 133.866k (± 2.5%) i/s - 678.350k in 5.070899s
1273
+ # Dry::Transaction 7.975k8.6%) i/s - 39.861k in 5.036260s
1274
+ # Micro::Case 130.534k24.4%) i/s - 583.401k in 5.040907s
1275
+ # Micro::Case::Safe 140.794k8.1%) i/s - 700.488k in 5.020935s
1276
+ # Micro::Case::Strict 102.641k21.3%) i/s - 480.280k in 5.020354s
1272
1277
 
1273
1278
  # Comparison:
1274
- # Micro::Case: 98820.8 i/s
1275
- # Micro::Case::Safe: 98695.0 i/s - same-ish: difference falls within error
1276
- # Micro::Case::Strict: 79935.9 i/s - 1.24x (± 0.00) slower
1277
- # Dry::Monads: 71329.7 i/s - 1.39x (± 0.00) slower
1278
- # Trailblazer::Operation: 15034.9 i/s - 6.57x (± 0.00) slower
1279
- # Interactor: 13958.7 i/s - 7.08x (± 0.00) slower
1280
- # Dry::Transaction: 5067.5 i/s - 19.50x (± 0.00) slower
1279
+ # Micro::Case::Safe: 140794.0 i/s
1280
+ # Dry::Monads: 133865.5 i/s - same-ish: difference falls within error
1281
+ # Micro::Case: 130534.0 i/s - same-ish: difference falls within error
1282
+ # Micro::Case::Strict: 102640.7 i/s - 1.37x (± 0.00) slower
1283
+ # Trailblazer::Operation: 39829.9 i/s - 3.53x (± 0.00) slower
1284
+ # Interactor: 23856.0 i/s - 5.90x (± 0.00) slower
1285
+ # Dry::Transaction: 7975.0 i/s - 17.65x (± 0.00) slower
1281
1286
  ```
1282
1287
  </details>
1283
1288
 
1284
- 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.
1285
1290
 
1286
1291
  ---
1287
1292
 
1288
1293
  ### `Micro::Cases::Flow`
1289
1294
 
1290
- | Gem / Abstração | [Resultados de sucesso](https://github.com/serradura/u-case/blob/main/benchmarks/flow/with_success_result.rb#L40) | [Resultados de falha](https://github.com/serradura/u-case/blob/main/benchmarks/flow/with_failure_result.rb#L40) |
1295
+ | Gem / Abstração | [Resultados de sucesso](https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/flow/success_results.rb) | [Resultados de falha](https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/flow/failure_results.rb) |
1291
1296
  | ------------------------------------------- | ----------------: | ----------------: |
1292
- | Micro::Case internal flow (private methods) | _**O mais rápido**_ | _**O mais rápido**_ |
1293
- | Micro::Case internal flow (through lambdas) | 1.03x slower | 1.04x slower |
1294
- | Micro::Case `then` method | 1.49x slower | 0x slower |
1295
- | Micro::Cases.flow | 1.53x slower | 1.04x slower |
1296
- | Micro::Cases.safe_flow | 1.54x slower | 1.04x slower |
1297
- | Interactor::Organizer | 2.05x slower | 6.27x slower |
1297
+ | Micro::Case::Result `pipe` method | 172734.4 i/s | 153745.6 i/s |
1298
+ | Micro::Case::Result `then` method | 1.24x mais devagar | 1.21x mais devagar |
1299
+ | Micro::Cases.flow | 1.30x mais devagar | 1.30x mais devagar |
1300
+ | Micro::Case class with an inner flow | 2.05x mais devagar | 1.98x mais devagar |
1301
+ | Micro::Case class including itself as a step| 2.14x mais devagar | 2.09x mais devagar |
1302
+ | Interactor::Organizer | 7.69x mais devagar | 7.03x mais devagar |
1298
1303
 
1299
1304
  \* As gems `Dry::Monads`, `Dry::Transaction`, `Trailblazer::Operation` estão fora desta análise por não terem esse tipo de funcionalidade.
1300
1305
 
@@ -1303,40 +1308,28 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_r
1303
1308
 
1304
1309
  ```ruby
1305
1310
  # Warming up --------------------------------------
1306
- # Interactor::Organizer
1307
- # 4.837k i/100ms
1308
- # Micro::Cases.flow([])
1309
- # 6.755k i/100ms
1310
- # Micro::Cases::safe_flow([])
1311
- # 6.809k i/100ms
1312
- # Micro::Case flow using `then` method
1313
- # 6.968k i/100ms
1314
- # Micro::Case flow using private methods
1315
- # 10.362k i/100ms
1316
- # Micro::Case flow using private methods through lambdas
1317
- # 10.258k i/100ms
1311
+ # Interactor::Organizer 2.163k i/100ms
1312
+ # Micro::Cases.flow([]) 13.158k i/100ms
1313
+ # Micro::Case flow in a class 8.400k i/100ms
1314
+ # Micro::Case including the class 8.008k i/100ms
1315
+ # Micro::Case::Result#| 17.151k i/100ms
1316
+ # Micro::Case::Result#then 14.121k i/100ms
1318
1317
 
1319
1318
  # Calculating -------------------------------------
1320
- # Interactor::Organizer
1321
- # 50.731k (± 1.6%) i/s - 256.361k in 5.054694s
1322
- # Micro::Cases.flow([])
1323
- # 67.757k (± 1.6%) i/s - 344.505k in 5.085681s
1324
- # Micro::Cases::safe_flow([])
1325
- # 67.613k (± 1.6%) i/s - 340.450k in 5.036562s
1326
- # Micro::Case flow using `then` method
1327
- # 69.483k (± 1.5%) i/s - 348.400k in 5.015351s
1328
- # Micro::Case flow using private methods
1329
- # 103.788k (± 1.0%) i/s - 528.462k in 5.092240s
1330
- # Micro::Case flow using private methods through lambdas
1331
- # 101.081k (± 1.2%) i/s - 512.900k in 5.074904s
1319
+ # Interactor::Organizer 22.467k (± 1.8%) i/s - 112.476k in 5.007787s
1320
+ # Micro::Cases.flow([]) 133.183k (± 1.5%) i/s - 671.058k in 5.039815s
1321
+ # Micro::Case flow in a class 84.083k (± 1.8%) i/s - 428.400k in 5.096623s
1322
+ # Micro::Case including the class 80.574k (± 1.6%) i/s - 408.408k in 5.070029s
1323
+ # Micro::Case::Result#| 172.734k (± 1.1%) i/s - 874.701k in 5.064429s
1324
+ # Micro::Case::Result#then 139.799k (± 1.7%) i/s - 706.050k in 5.052035s
1332
1325
 
1333
1326
  # Comparison:
1334
- # Micro::Case flow using private methods: 103787.5 i/s
1335
- # Micro::Case flow using private methods through lambdas: 101080.6 i/s - 1.03x (± 0.00) slower
1336
- # Micro::Case flow using `then` method: 69483.3 i/s - 1.49x (± 0.00) slower
1337
- # Micro::Cases.flow([]): 67757.2 i/s - 1.53x (± 0.00) slower
1338
- # Micro::Cases::safe_flow([]): 67613.3 i/s - 1.54x (± 0.00) slower
1339
- # Interactor::Organizer: 50730.8 i/s - 2.05x (± 0.00) slower
1327
+ # Micro::Case::Result#|: 172734.4 i/s
1328
+ # Micro::Case::Result#then: 139799.0 i/s - 1.24x (± 0.00) slower
1329
+ # Micro::Cases.flow([]): 133182.9 i/s - 1.30x (± 0.00) slower
1330
+ # Micro::Case flow in a class: 84082.6 i/s - 2.05x (± 0.00) slower
1331
+ # Micro::Case including the class: 80574.3 i/s - 2.14x (± 0.00) slower
1332
+ # Interactor::Organizer: 22467.4 i/s - 7.69x (± 0.00) slower
1340
1333
  ```
1341
1334
  </details>
1342
1335
 
@@ -1345,43 +1338,72 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_r
1345
1338
 
1346
1339
  ```ruby
1347
1340
  # Warming up --------------------------------------
1348
- # Interactor::Organizer
1349
- # 2.299k i/100ms
1350
- # Micro::Cases.flow([])
1351
- # 14.187k i/100ms
1352
- # Micro::Cases::safe_flow([])
1353
- # 13.609k i/100ms
1354
- # Micro::Case flow using `then` method
1355
- # 14.578k i/100ms
1356
- # Micro::Case flow using private methods
1357
- # 14.101k i/100ms
1358
- # Micro::Case flow using private methods through lambdas
1359
- # 13.670k i/100ms
1341
+ # Interactor::Organizer 2.167k i/100ms
1342
+ # Micro::Cases.flow([]) 11.797k i/100ms
1343
+ # Micro::Case flow in a class 7.783k i/100ms
1344
+ # Micro::Case including the class 7.097k i/100ms
1345
+ # Micro::Case::Result#| 14.398k i/100ms
1346
+ # Micro::Case::Result#then 12.719k i/100ms
1347
+
1360
1348
  # Calculating -------------------------------------
1361
- # Interactor::Organizer
1362
- # 23.306k2.1%) i/s - 117.249k in 5.033171s
1363
- # Micro::Cases.flow([])
1364
- # 140.111k (± 1.6%) i/s - 709.350k in 5.064041s
1365
- # Micro::Cases::safe_flow([])
1366
- # 139.927k (± 1.7%) i/s - 707.668k in 5.058971s
1367
- # Micro::Case flow using `then` method
1368
- # 146.073k (± 2.0%) i/s - 743.478k in 5.091741s
1369
- # Micro::Case flow using private methods
1370
- # 142.092k (± 1.5%) i/s - 719.151k in 5.062298s
1371
- # Micro::Case flow using private methods through lambdas
1372
- # 140.791k (± 1.2%) i/s - 710.840k in 5.049584s
1349
+ # Interactor::Organizer 21.863k (± 2.5%) i/s - 110.517k in 5.058420s
1350
+ # Micro::Cases.flow([]) 118.124k1.8%) i/s - 601.647k in 5.095102s
1351
+ # Micro::Case flow in a class 77.801k (± 1.5%) i/s - 389.150k in 5.003002s
1352
+ # Micro::Case including the class 73.533k2.1%) i/s - 369.044k in 5.021076s
1353
+ # Micro::Case::Result#| 153.746k (± 1.5%) i/s - 777.492k in 5.058177s
1354
+ # Micro::Case::Result#then 126.897k (± 1.7%) i/s - 635.950k in 5.013059s
1373
1355
 
1374
1356
  # Comparison:
1375
- # Micro::Case flow using `then` method: 146073.0 i/s
1376
- # Micro::Case flow using private methods: 142091.7 i/s - same-ish: difference falls within error
1377
- # Micro::Case flow using private methods through lambdas: 140791.1 i/s - 1.04x (± 0.00) slower
1378
- # Micro::Cases.flow([]): 140110.8 i/s - 1.04x (± 0.00) slower
1379
- # Micro::Cases::safe_flow([]): 139926.6 i/s - 1.04x (± 0.00) slower
1380
- # Interactor::Organizer: 23305.9 i/s - 6.27x (± 0.00) slower
1357
+ # Micro::Case::Result#|: 153745.6 i/s
1358
+ # Micro::Case::Result#then: 126896.6 i/s - 1.21x (± 0.00) slower
1359
+ # Micro::Cases.flow([]): 118123.9 i/s - 1.30x (± 0.00) slower
1360
+ # Micro::Case flow in a class: 77800.7 i/s - 1.98x (± 0.00) slower
1361
+ # Micro::Case including the class: 73532.9 i/s - 2.09x (± 0.00) slower
1362
+ # Interactor::Organizer: 21862.9 i/s - 7.03x (± 0.00) slower
1381
1363
  ```
1382
1364
  </details>
1383
1365
 
1384
- https://github.com/serradura/u-case/tree/main/benchmarks/flow
1366
+ https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/flow/
1367
+
1368
+ [⬆️ Voltar para o índice](#índice-)
1369
+
1370
+ ### Execuntando os benchmarks
1371
+
1372
+ #### Performance (Benchmarks IPS)
1373
+
1374
+ Clone este repositório e acesse a sua pasta, então execute os comandos abaixo:
1375
+
1376
+ **Casos de uso**
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
+ **Casos de uso**
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
+ [⬆️ Voltar para o índice](#índice-)
1385
1407
 
1386
1408
  ### Comparações
1387
1409
 
@@ -16,7 +16,7 @@ module Micro
16
16
 
17
17
  require 'micro/cases'
18
18
 
19
- include Micro::Attributes.without(:strict_initialize)
19
+ include Micro::Attributes.with(:initialize, :diff)
20
20
 
21
21
  def self.call(options = Kind::Empty::HASH)
22
22
  new(options).__call__
@@ -63,7 +63,8 @@ module Micro
63
63
  end
64
64
 
65
65
  def self.inherited(subclass)
66
- subclass.attributes(self.attributes_data({}))
66
+ subclass.__attributes_set_after_inherit__(self.__attributes_data__)
67
+
67
68
  subclass.extend ::Micro::Attributes.const_get('Macros::ForSubclasses'.freeze)
68
69
 
69
70
  if self.send(:__flow_use_cases) && !subclass.name.to_s.end_with?(FLOW_STEP)
@@ -52,7 +52,10 @@ module Micro
52
52
  end
53
53
 
54
54
  def self.by_wrong_usage?(exception)
55
- exception.is_a?(InvalidResult) || exception.is_a?(UnexpectedResult) || exception.is_a?(ArgumentError)
55
+ case exception
56
+ when Kind::Error, ArgumentError, InvalidResult, UnexpectedResult then true
57
+ else false
58
+ end
56
59
  end
57
60
  end
58
61
  end
@@ -22,20 +22,24 @@ module Micro
22
22
 
23
23
  alias value data
24
24
 
25
- def initialize(transitions_mapper = nil)
25
+ def initialize(transitions_mapper = Transitions::MapEverything)
26
26
  @__accumulated_data = {}
27
27
  @__accessible_attributes = {}
28
28
 
29
29
  enable_transitions = @@transitions_enabled
30
30
 
31
31
  @__transitions = enable_transitions ? [] : Kind::Empty::ARRAY
32
- @__transitions_mapper = transitions_mapper || Transitions::MapEverything if enable_transitions
32
+ @__transitions_mapper = transitions_mapper if enable_transitions
33
33
  end
34
34
 
35
35
  def to_ary
36
36
  [data, type]
37
37
  end
38
38
 
39
+ def to_sym
40
+ @__success ? :success : :failure
41
+ end
42
+
39
43
  def [](key)
40
44
  data[key]
41
45
  end
@@ -5,11 +5,9 @@ module Micro
5
5
  class Result
6
6
  class Transitions
7
7
  MapEverything = -> (result, use_case_attributes) do
8
- result_track = result.success? ? :success : :failure
9
-
10
8
  {
11
9
  use_case: { class: result.use_case.class, attributes: use_case_attributes },
12
- result_track => { type: result.type, result: result.data },
10
+ result.to_sym => { type: result.type, result: result.data },
13
11
  accessible_attributes: result.accessible_attributes
14
12
  }
15
13
  end
@@ -3,10 +3,10 @@
3
3
  module Micro
4
4
  class Case
5
5
  class Strict < ::Micro::Case
6
- include Micro::Attributes::Features::StrictInitialize
6
+ include Micro::Attributes::Features::Initialize::Strict
7
7
 
8
8
  class Safe < ::Micro::Case::Safe
9
- include Micro::Attributes::Features::StrictInitialize
9
+ include Micro::Attributes::Features::Initialize::Strict
10
10
  end
11
11
  end
12
12
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Micro
4
4
  class Case
5
- VERSION = '3.1.0'.freeze
5
+ VERSION = '4.0.0'.freeze
6
6
  end
7
7
  end
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Rodrigo Serradura']
10
10
  spec.email = ['rodrigo.serradura@gmail.com']
11
11
 
12
- spec.summary = %q{Create simple and powerful use cases as Ruby objects.}
13
- spec.description = %q{Create simple and powerful use cases as Ruby objects.}
12
+ spec.summary = %q{Represent use cases in a simple and powerful way while writing modular, expressive and sequentially logical code.}
13
+ spec.description = %q{Represent use cases in a simple and powerful way while writing modular, expressive and sequentially logical code.}
14
14
  spec.homepage = 'https://github.com/serradura/u-case'
15
15
  spec.license = 'MIT'
16
16
 
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.required_ruby_version = '>= 2.2.0'
27
27
 
28
28
  spec.add_runtime_dependency 'kind', '>= 3.0', '< 5.0'
29
- spec.add_runtime_dependency 'u-attributes', '~> 1.1'
29
+ spec.add_runtime_dependency 'u-attributes', '~> 2.0'
30
30
 
31
31
  spec.add_development_dependency 'bundler'
32
32
  spec.add_development_dependency 'rake', '~> 13.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: u-case
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Serradura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-18 00:00:00.000000000 Z
11
+ date: 2020-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kind
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '1.1'
39
+ version: '2.0'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '1.1'
46
+ version: '2.0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -72,7 +72,8 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '13.0'
75
- description: Create simple and powerful use cases as Ruby objects.
75
+ description: Represent use cases in a simple and powerful way while writing modular,
76
+ expressive and sequentially logical code.
76
77
  email:
77
78
  - rodrigo.serradura@gmail.com
78
79
  executables: []
@@ -130,5 +131,6 @@ requirements: []
130
131
  rubygems_version: 3.0.6
131
132
  signing_key:
132
133
  specification_version: 4
133
- summary: Create simple and powerful use cases as Ruby objects.
134
+ summary: Represent use cases in a simple and powerful way while writing modular, expressive
135
+ and sequentially logical code.
134
136
  test_files: []