u-case 3.1.0 → 4.0.0
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 +4 -4
- data/README.md +153 -131
- data/README.pt-BR.md +153 -131
- data/lib/micro/case.rb +3 -2
- data/lib/micro/case/error.rb +4 -1
- data/lib/micro/case/result.rb +6 -2
- data/lib/micro/case/result/transitions.rb +1 -3
- data/lib/micro/case/strict.rb +2 -2
- data/lib/micro/case/version.rb +1 -1
- data/u-case.gemspec +3 -3
- metadata +8 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e5a9b11b39c8c90670c4308c91e4e887871eb8f98a1fb739c4be71885a14d0b8
|
|
4
|
+
data.tar.gz: d4ce16229a9afd7dd4d1a1cf8e5b11067a11a6317c6857264ba46b324b220994
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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 -
|
|
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>
|
|
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
|
-
|
|
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
|
-
|
|
|
100
|
-
|
|
|
101
|
-
|
|
|
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
|
|
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 |
|
|
1197
|
-
| **Micro::Case** |
|
|
1198
|
-
| Interactor |
|
|
1199
|
-
| Trailblazer::Operation |
|
|
1200
|
-
| Dry::Transaction |
|
|
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
|
|
1208
|
-
# Trailblazer::Operation
|
|
1209
|
-
# Dry::Monads
|
|
1210
|
-
# Dry::Transaction
|
|
1211
|
-
# Micro::Case
|
|
1212
|
-
#
|
|
1213
|
-
#
|
|
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
|
|
1217
|
-
# Trailblazer::Operation
|
|
1218
|
-
# Dry::Monads
|
|
1219
|
-
# Dry::Transaction
|
|
1220
|
-
# Micro::Case
|
|
1221
|
-
#
|
|
1222
|
-
#
|
|
1221
|
+
# Interactor 53.016k (± 1.8%) i/s - 267.852k in 5.053967s
|
|
1222
|
+
# Trailblazer::Operation 38.314k (± 1.7%) i/s - 194.055k in 5.066374s
|
|
1223
|
+
# Dry::Monads 281.515k (± 2.4%) i/s - 1.408M in 5.003266s
|
|
1224
|
+
# Dry::Transaction 10.441k (± 2.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.801k (± 6.7%) i/s - 728.256k in 5.022666s
|
|
1227
|
+
# Micro::Case::Strict 115.636k (± 8.4%) i/s - 577.622k in 5.042079s
|
|
1223
1228
|
|
|
1224
1229
|
# Comparison:
|
|
1225
|
-
# Dry::Monads:
|
|
1226
|
-
# Micro::Case:
|
|
1227
|
-
# Micro::Case::Safe:
|
|
1228
|
-
# Micro::Case::Strict:
|
|
1229
|
-
# Interactor:
|
|
1230
|
-
# Trailblazer::Operation:
|
|
1231
|
-
# Dry::Transaction:
|
|
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/
|
|
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** |
|
|
1242
|
-
| Dry::Monads |
|
|
1243
|
-
| Trailblazer::Operation |
|
|
1244
|
-
| Interactor |
|
|
1245
|
-
| Dry::Transaction |
|
|
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
|
|
1253
|
-
# Trailblazer::Operation
|
|
1254
|
-
# Dry::Monads
|
|
1255
|
-
# Dry::Transaction
|
|
1256
|
-
# Micro::Case
|
|
1257
|
-
#
|
|
1258
|
-
#
|
|
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
|
|
1262
|
-
# Trailblazer::Operation
|
|
1263
|
-
# Dry::Monads
|
|
1264
|
-
# Dry::Transaction
|
|
1265
|
-
# Micro::Case
|
|
1266
|
-
#
|
|
1267
|
-
#
|
|
1266
|
+
# Interactor 23.856k (± 1.7%) i/s - 119.901k in 5.027585s
|
|
1267
|
+
# Trailblazer::Operation 39.830k (± 1.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.975k (± 8.6%) i/s - 39.861k in 5.036260s
|
|
1270
|
+
# Micro::Case 130.534k (±24.4%) i/s - 583.401k in 5.040907s
|
|
1271
|
+
# Micro::Case::Safe 140.794k (± 8.1%) i/s - 700.488k in 5.020935s
|
|
1272
|
+
# Micro::Case::Strict 102.641k (±21.3%) i/s - 480.280k in 5.020354s
|
|
1268
1273
|
|
|
1269
1274
|
# Comparison:
|
|
1270
|
-
#
|
|
1271
|
-
#
|
|
1272
|
-
#
|
|
1273
|
-
#
|
|
1274
|
-
# Trailblazer::Operation:
|
|
1275
|
-
# Interactor:
|
|
1276
|
-
# Dry::Transaction:
|
|
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/
|
|
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/
|
|
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
|
|
1289
|
-
| Micro::Case
|
|
1290
|
-
| Micro::
|
|
1291
|
-
| Micro::
|
|
1292
|
-
| Micro::
|
|
1293
|
-
| Interactor::Organizer |
|
|
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
|
-
#
|
|
1304
|
-
# Micro::
|
|
1305
|
-
#
|
|
1306
|
-
# Micro::
|
|
1307
|
-
#
|
|
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
|
-
#
|
|
1318
|
-
# Micro::
|
|
1319
|
-
#
|
|
1320
|
-
# Micro::
|
|
1321
|
-
#
|
|
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
|
|
1331
|
-
# Micro::Case
|
|
1332
|
-
# Micro::
|
|
1333
|
-
# Micro::
|
|
1334
|
-
# Micro::
|
|
1335
|
-
# Interactor::Organizer:
|
|
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
|
-
#
|
|
1346
|
-
# Micro::
|
|
1347
|
-
#
|
|
1348
|
-
# Micro::
|
|
1349
|
-
#
|
|
1350
|
-
|
|
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
|
-
#
|
|
1359
|
-
# Micro::
|
|
1360
|
-
#
|
|
1361
|
-
# Micro::
|
|
1362
|
-
#
|
|
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.124k (± 1.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.533k (± 2.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
|
|
1372
|
-
# Micro::Case
|
|
1373
|
-
# Micro::
|
|
1374
|
-
# Micro::
|
|
1375
|
-
# Micro::
|
|
1376
|
-
# Interactor::Organizer:
|
|
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/
|
|
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
|
|
data/README.pt-BR.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="./assets/ucase_logo_v1.png" alt="u-case -
|
|
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>
|
|
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
|
-
|
|
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
|
-
|
|
|
99
|
-
|
|
|
100
|
-
|
|
|
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
|
|
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 |
|
|
1201
|
-
| **Micro::Case** |
|
|
1202
|
-
| Interactor |
|
|
1203
|
-
| Trailblazer::Operation |
|
|
1204
|
-
| Dry::Transaction |
|
|
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
|
|
1212
|
-
# Trailblazer::Operation
|
|
1213
|
-
# Dry::Monads
|
|
1214
|
-
# Dry::Transaction
|
|
1215
|
-
# Micro::Case
|
|
1216
|
-
#
|
|
1217
|
-
#
|
|
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
|
|
1221
|
-
# Trailblazer::Operation
|
|
1222
|
-
# Dry::Monads
|
|
1223
|
-
# Dry::Transaction
|
|
1224
|
-
# Micro::Case
|
|
1225
|
-
#
|
|
1226
|
-
#
|
|
1225
|
+
# Interactor 53.016k (± 1.8%) i/s - 267.852k in 5.053967s
|
|
1226
|
+
# Trailblazer::Operation 38.314k (± 1.7%) i/s - 194.055k in 5.066374s
|
|
1227
|
+
# Dry::Monads 281.515k (± 2.4%) i/s - 1.408M in 5.003266s
|
|
1228
|
+
# Dry::Transaction 10.441k (± 2.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.801k (± 6.7%) i/s - 728.256k in 5.022666s
|
|
1231
|
+
# Micro::Case::Strict 115.636k (± 8.4%) i/s - 577.622k in 5.042079s
|
|
1227
1232
|
|
|
1228
1233
|
# Comparison:
|
|
1229
|
-
# Dry::Monads:
|
|
1230
|
-
# Micro::Case:
|
|
1231
|
-
# Micro::Case::Safe:
|
|
1232
|
-
# Micro::Case::Strict:
|
|
1233
|
-
# Interactor:
|
|
1234
|
-
# Trailblazer::Operation:
|
|
1235
|
-
# Dry::Transaction:
|
|
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/
|
|
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** |
|
|
1246
|
-
| Dry::Monads |
|
|
1247
|
-
| Trailblazer::Operation |
|
|
1248
|
-
| Interactor |
|
|
1249
|
-
| Dry::Transaction |
|
|
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
|
|
1257
|
-
# Trailblazer::Operation
|
|
1258
|
-
# Dry::Monads
|
|
1259
|
-
# Dry::Transaction
|
|
1260
|
-
# Micro::Case
|
|
1261
|
-
#
|
|
1262
|
-
#
|
|
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
|
|
1266
|
-
# Trailblazer::Operation
|
|
1267
|
-
# Dry::Monads
|
|
1268
|
-
# Dry::Transaction
|
|
1269
|
-
# Micro::Case
|
|
1270
|
-
#
|
|
1271
|
-
#
|
|
1270
|
+
# Interactor 23.856k (± 1.7%) i/s - 119.901k in 5.027585s
|
|
1271
|
+
# Trailblazer::Operation 39.830k (± 1.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.975k (± 8.6%) i/s - 39.861k in 5.036260s
|
|
1274
|
+
# Micro::Case 130.534k (±24.4%) i/s - 583.401k in 5.040907s
|
|
1275
|
+
# Micro::Case::Safe 140.794k (± 8.1%) i/s - 700.488k in 5.020935s
|
|
1276
|
+
# Micro::Case::Strict 102.641k (±21.3%) i/s - 480.280k in 5.020354s
|
|
1272
1277
|
|
|
1273
1278
|
# Comparison:
|
|
1274
|
-
#
|
|
1275
|
-
#
|
|
1276
|
-
#
|
|
1277
|
-
#
|
|
1278
|
-
# Trailblazer::Operation:
|
|
1279
|
-
# Interactor:
|
|
1280
|
-
# Dry::Transaction:
|
|
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/
|
|
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/
|
|
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
|
|
1293
|
-
| Micro::Case
|
|
1294
|
-
| Micro::
|
|
1295
|
-
| Micro::
|
|
1296
|
-
| Micro::
|
|
1297
|
-
| Interactor::Organizer |
|
|
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
|
-
#
|
|
1308
|
-
# Micro::
|
|
1309
|
-
#
|
|
1310
|
-
# Micro::
|
|
1311
|
-
#
|
|
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
|
-
#
|
|
1322
|
-
# Micro::
|
|
1323
|
-
#
|
|
1324
|
-
# Micro::
|
|
1325
|
-
#
|
|
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
|
|
1335
|
-
# Micro::Case
|
|
1336
|
-
# Micro::
|
|
1337
|
-
# Micro::
|
|
1338
|
-
# Micro::
|
|
1339
|
-
# Interactor::Organizer:
|
|
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
|
-
#
|
|
1350
|
-
# Micro::
|
|
1351
|
-
#
|
|
1352
|
-
# Micro::
|
|
1353
|
-
#
|
|
1354
|
-
|
|
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
|
-
#
|
|
1363
|
-
# Micro::
|
|
1364
|
-
#
|
|
1365
|
-
# Micro::
|
|
1366
|
-
#
|
|
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.124k (± 1.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.533k (± 2.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
|
|
1376
|
-
# Micro::Case
|
|
1377
|
-
# Micro::
|
|
1378
|
-
# Micro::
|
|
1379
|
-
# Micro::
|
|
1380
|
-
# Interactor::Organizer:
|
|
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/
|
|
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
|
|
data/lib/micro/case.rb
CHANGED
|
@@ -16,7 +16,7 @@ module Micro
|
|
|
16
16
|
|
|
17
17
|
require 'micro/cases'
|
|
18
18
|
|
|
19
|
-
include Micro::Attributes.
|
|
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.
|
|
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)
|
data/lib/micro/case/error.rb
CHANGED
|
@@ -52,7 +52,10 @@ module Micro
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def self.by_wrong_usage?(exception)
|
|
55
|
-
|
|
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
|
data/lib/micro/case/result.rb
CHANGED
|
@@ -22,20 +22,24 @@ module Micro
|
|
|
22
22
|
|
|
23
23
|
alias value data
|
|
24
24
|
|
|
25
|
-
def initialize(transitions_mapper =
|
|
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
|
|
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
|
-
|
|
10
|
+
result.to_sym => { type: result.type, result: result.data },
|
|
13
11
|
accessible_attributes: result.accessible_attributes
|
|
14
12
|
}
|
|
15
13
|
end
|
data/lib/micro/case/strict.rb
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
module Micro
|
|
4
4
|
class Case
|
|
5
5
|
class Strict < ::Micro::Case
|
|
6
|
-
include Micro::Attributes::Features::
|
|
6
|
+
include Micro::Attributes::Features::Initialize::Strict
|
|
7
7
|
|
|
8
8
|
class Safe < ::Micro::Case::Safe
|
|
9
|
-
include Micro::Attributes::Features::
|
|
9
|
+
include Micro::Attributes::Features::Initialize::Strict
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
end
|
data/lib/micro/case/version.rb
CHANGED
data/u-case.gemspec
CHANGED
|
@@ -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{
|
|
13
|
-
spec.description = %q{
|
|
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', '~>
|
|
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:
|
|
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-
|
|
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: '
|
|
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: '
|
|
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:
|
|
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:
|
|
134
|
+
summary: Represent use cases in a simple and powerful way while writing modular, expressive
|
|
135
|
+
and sequentially logical code.
|
|
134
136
|
test_files: []
|