u-case 3.0.0.rc8 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.sh +4 -4
- data/Gemfile +9 -1
- data/README.md +183 -142
- data/README.pt-BR.md +203 -163
- data/lib/micro/case.rb +56 -26
- data/lib/micro/case/config.rb +16 -4
- data/lib/micro/case/error.rb +7 -2
- data/lib/micro/case/result.rb +80 -44
- data/lib/micro/case/result/transitions.rb +17 -0
- data/lib/micro/case/result/wrapper.rb +45 -0
- data/lib/micro/case/safe.rb +2 -2
- data/lib/micro/case/strict.rb +2 -2
- data/lib/micro/case/utils.rb +20 -10
- data/lib/micro/case/version.rb +1 -1
- data/lib/micro/case/with_activemodel_validation.rb +3 -1
- data/lib/micro/cases.rb +7 -0
- data/lib/micro/cases/error.rb +13 -0
- data/lib/micro/cases/flow.rb +37 -24
- data/lib/micro/cases/map.rb +39 -0
- data/lib/micro/cases/safe/flow.rb +2 -2
- data/lib/micro/cases/utils.rb +21 -0
- data/u-case.gemspec +3 -3
- metadata +15 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e43c3e14dcb10002feb94f83f7d9289b49164e5908f3e8b58fa64e62d69796db
|
4
|
+
data.tar.gz: 9f3a37d02e5e1c1369f74e8cdf14cc3038fad55df5db08bd1a330dd7004e5ba1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 744d7c78a228a3ae9197762f9e259dd72ab2f1b8c20af968fca4cbe46931c703abd9aa051c4aa0669b61f51b14d42a990834dc4fc34dc2f60a9f20d68867fbab
|
7
|
+
data.tar.gz: 7da45bc3752296dd000bf016ef35ff7c993d0ea5c2218e43e6f1d492ec7d41f457e7048cf8b281d0ecb6f40efe05df19d07809d69db3a7a41df02f10028a7e68
|
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
|
-
|
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
|
-
|
2
|
-
|
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
|
-
<
|
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
|
-
|
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
|
-
|
41
|
+
unreleased| https://github.com/serradura/u-case/blob/main/README.md
|
42
|
+
4.1.0 | 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`
|
82
|
+
- [`Micro::Case`](#microcase)
|
64
83
|
- [Success results](#success-results)
|
65
84
|
- [Failure results](#failure-results)
|
66
|
-
- [`Micro::Cases::Flow`
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
102
|
+
| u-case | branch | ruby | activemodel | u-attributes |
|
103
|
+
| -------------- | ------- | -------- | ------------- | ------------ |
|
104
|
+
| unreleased | main | >= 2.2.0 | >= 3.2, < 6.1 | ~> 2.0 |
|
105
|
+
| 4.1.0 | 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', '~>
|
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
|
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 :
|
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,110 @@ end
|
|
1170
1194
|
|
1171
1195
|
## Benchmarks
|
1172
1196
|
|
1173
|
-
### `Micro::Case`
|
1197
|
+
### `Micro::Case`
|
1174
1198
|
|
1175
1199
|
#### Success results
|
1176
1200
|
|
1177
1201
|
| Gem / Abstraction | Iterations per second | Comparison |
|
1178
1202
|
| ----------------- | --------------------: | ----------------: |
|
1179
|
-
| Dry::Monads |
|
1180
|
-
| **Micro::Case** |
|
1181
|
-
| Interactor |
|
1182
|
-
| Trailblazer::Operation |
|
1183
|
-
| Dry::Transaction |
|
1203
|
+
| Dry::Monads | 281515.4 | _**The Fastest**_ |
|
1204
|
+
| **Micro::Case** | 151711.3 | 1.86x slower |
|
1205
|
+
| Interactor | 53016.2 | 5.31x slower |
|
1206
|
+
| Trailblazer::Operation | 38314.2 | 7.35x slower |
|
1207
|
+
| Dry::Transaction | 10440.7 | 26.96x 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
|
1191
|
-
# Trailblazer::Operation
|
1192
|
-
# Dry::Monads
|
1193
|
-
# Dry::Transaction
|
1194
|
-
# Micro::Case
|
1195
|
-
#
|
1196
|
-
#
|
1214
|
+
# Interactor 5.151k i/100ms
|
1215
|
+
# Trailblazer::Operation 3.805k i/100ms
|
1216
|
+
# Dry::Monads 28.153k i/100ms
|
1217
|
+
# Dry::Transaction 1.063k i/100ms
|
1218
|
+
# Micro::Case 15.159k i/100ms
|
1219
|
+
# Micro::Case::Safe 15.172k i/100ms
|
1220
|
+
# Micro::Case::Strict 12.557k i/100ms
|
1197
1221
|
|
1198
1222
|
# Calculating -------------------------------------
|
1199
|
-
# Interactor
|
1200
|
-
# Trailblazer::Operation
|
1201
|
-
# Dry::Monads
|
1202
|
-
# Dry::Transaction
|
1203
|
-
# Micro::Case
|
1204
|
-
#
|
1205
|
-
#
|
1223
|
+
# Interactor 53.016k (± 1.8%) i/s - 267.852k in 5.053967s
|
1224
|
+
# Trailblazer::Operation 38.314k (± 1.7%) i/s - 194.055k in 5.066374s
|
1225
|
+
# Dry::Monads 281.515k (± 2.4%) i/s - 1.408M in 5.003266s
|
1226
|
+
# Dry::Transaction 10.441k (± 2.1%) i/s - 53.150k in 5.092957s
|
1227
|
+
# Micro::Case 151.711k (± 1.7%) i/s - 773.109k in 5.097555s
|
1228
|
+
# Micro::Case::Safe 145.801k (± 6.7%) i/s - 728.256k in 5.022666s
|
1229
|
+
# Micro::Case::Strict 115.636k (± 8.4%) i/s - 577.622k in 5.042079s
|
1206
1230
|
|
1207
1231
|
# Comparison:
|
1208
|
-
# Dry::Monads:
|
1209
|
-
# Micro::Case:
|
1210
|
-
# Micro::Case::Safe:
|
1211
|
-
# Micro::Case::Strict:
|
1212
|
-
# Interactor:
|
1213
|
-
# Trailblazer::Operation:
|
1214
|
-
# Dry::Transaction:
|
1232
|
+
# Dry::Monads: 281515.4 i/s
|
1233
|
+
# Micro::Case: 151711.3 i/s - 1.86x (± 0.00) slower
|
1234
|
+
# Micro::Case::Safe: 145800.8 i/s - 1.93x (± 0.00) slower
|
1235
|
+
# Micro::Case::Strict: 115635.8 i/s - 2.43x (± 0.00) slower
|
1236
|
+
# Interactor: 53016.2 i/s - 5.31x (± 0.00) slower
|
1237
|
+
# Trailblazer::Operation: 38314.2 i/s - 7.35x (± 0.00) slower
|
1238
|
+
# Dry::Transaction: 10440.7 i/s - 26.96x (± 0.00) slower
|
1215
1239
|
```
|
1216
1240
|
</details>
|
1217
1241
|
|
1218
|
-
https://github.com/serradura/u-case/blob/main/benchmarks/use_case/
|
1242
|
+
https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/use_case/success_results.rb
|
1219
1243
|
|
1220
1244
|
#### Failure results
|
1221
1245
|
|
1222
1246
|
| Gem / Abstraction | Iterations per second | Comparison |
|
1223
1247
|
| ----------------- | --------------------: | ----------------: |
|
1224
|
-
| **Micro::Case** |
|
1225
|
-
| Dry::Monads |
|
1226
|
-
| Trailblazer::Operation |
|
1227
|
-
| Interactor |
|
1228
|
-
| Dry::Transaction |
|
1248
|
+
| **Micro::Case** | 140794.0 | _**The Fastest**_ |
|
1249
|
+
| Dry::Monads | 133865.5 | 0x slower |
|
1250
|
+
| Trailblazer::Operation | 39829.9 | 3.53x slower |
|
1251
|
+
| Interactor | 23856.0 | 5.90x slower |
|
1252
|
+
| Dry::Transaction | 7975.0 | 17.65x slower |
|
1229
1253
|
|
1230
1254
|
<details>
|
1231
1255
|
<summary>Show the full <a href="https://github.com/evanphx/benchmark-ips">benchmark/ips</a> results.</summary>
|
1232
1256
|
|
1233
1257
|
```ruby
|
1234
1258
|
# Warming up --------------------------------------
|
1235
|
-
# Interactor
|
1236
|
-
# Trailblazer::Operation
|
1237
|
-
# Dry::Monads
|
1238
|
-
# Dry::Transaction
|
1239
|
-
# Micro::Case
|
1240
|
-
#
|
1241
|
-
#
|
1259
|
+
# Interactor 2.351k i/100ms
|
1260
|
+
# Trailblazer::Operation 3.941k i/100ms
|
1261
|
+
# Dry::Monads 13.567k i/100ms
|
1262
|
+
# Dry::Transaction 927.000 i/100ms
|
1263
|
+
# Micro::Case 14.959k i/100ms
|
1264
|
+
# Micro::Case::Safe 14.904k i/100ms
|
1265
|
+
# Micro::Case::Strict 12.007k i/100ms
|
1242
1266
|
|
1243
1267
|
# Calculating -------------------------------------
|
1244
|
-
# Interactor
|
1245
|
-
# Trailblazer::Operation
|
1246
|
-
# Dry::Monads
|
1247
|
-
# Dry::Transaction
|
1248
|
-
# Micro::Case
|
1249
|
-
#
|
1250
|
-
#
|
1268
|
+
# Interactor 23.856k (± 1.7%) i/s - 119.901k in 5.027585s
|
1269
|
+
# Trailblazer::Operation 39.830k (± 1.2%) i/s - 200.991k in 5.047032s
|
1270
|
+
# Dry::Monads 133.866k (± 2.5%) i/s - 678.350k in 5.070899s
|
1271
|
+
# Dry::Transaction 7.975k (± 8.6%) i/s - 39.861k in 5.036260s
|
1272
|
+
# Micro::Case 130.534k (±24.4%) i/s - 583.401k in 5.040907s
|
1273
|
+
# Micro::Case::Safe 140.794k (± 8.1%) i/s - 700.488k in 5.020935s
|
1274
|
+
# Micro::Case::Strict 102.641k (±21.3%) i/s - 480.280k in 5.020354s
|
1251
1275
|
|
1252
1276
|
# Comparison:
|
1253
|
-
#
|
1254
|
-
#
|
1255
|
-
#
|
1256
|
-
#
|
1257
|
-
# Trailblazer::Operation:
|
1258
|
-
# Interactor:
|
1259
|
-
# Dry::Transaction:
|
1277
|
+
# Micro::Case::Safe: 140794.0 i/s
|
1278
|
+
# Dry::Monads: 133865.5 i/s - same-ish: difference falls within error
|
1279
|
+
# Micro::Case: 130534.0 i/s - same-ish: difference falls within error
|
1280
|
+
# Micro::Case::Strict: 102640.7 i/s - 1.37x (± 0.00) slower
|
1281
|
+
# Trailblazer::Operation: 39829.9 i/s - 3.53x (± 0.00) slower
|
1282
|
+
# Interactor: 23856.0 i/s - 5.90x (± 0.00) slower
|
1283
|
+
# Dry::Transaction: 7975.0 i/s - 17.65x (± 0.00) slower
|
1260
1284
|
```
|
1261
1285
|
</details>
|
1262
1286
|
|
1263
|
-
https://github.com/serradura/u-case/blob/main/benchmarks/use_case/
|
1287
|
+
https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/use_case/failure_results.rb
|
1264
1288
|
|
1265
1289
|
---
|
1266
1290
|
|
1267
|
-
### `Micro::Cases::Flow`
|
1291
|
+
### `Micro::Cases::Flow`
|
1268
1292
|
|
1269
|
-
| Gems / Abstraction | [Success results](https://github.com/serradura/u-case/blob/main/benchmarks/flow/
|
1293
|
+
| 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
1294
|
| ------------------------------------------- | ----------------: | ----------------: |
|
1271
|
-
| Micro::Case
|
1272
|
-
| Micro::Case
|
1273
|
-
| Micro::
|
1274
|
-
| Micro::
|
1275
|
-
| Micro::
|
1276
|
-
| Interactor::Organizer |
|
1295
|
+
| Micro::Case::Result `pipe` method | 172734.4 i/s | 153745.6 i/s |
|
1296
|
+
| Micro::Case::Result `then` method | 1.24x slower | 1.21x slower |
|
1297
|
+
| Micro::Cases.flow | 1.30x slower | 1.30x slower |
|
1298
|
+
| Micro::Case class with an inner flow | 2.05x slower | 1.98x slower |
|
1299
|
+
| Micro::Case class including itself as a step| 2.14x slower | 2.09x slower |
|
1300
|
+
| Interactor::Organizer | 7.69x slower | 7.03x slower |
|
1277
1301
|
|
1278
1302
|
\* 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
1303
|
|
@@ -1282,40 +1306,28 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_r
|
|
1282
1306
|
|
1283
1307
|
```ruby
|
1284
1308
|
# Warming up --------------------------------------
|
1285
|
-
# Interactor::Organizer
|
1286
|
-
#
|
1287
|
-
# Micro::
|
1288
|
-
#
|
1289
|
-
# Micro::
|
1290
|
-
#
|
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
|
1309
|
+
# Interactor::Organizer 2.163k i/100ms
|
1310
|
+
# Micro::Cases.flow([]) 13.158k i/100ms
|
1311
|
+
# Micro::Case flow in a class 8.400k i/100ms
|
1312
|
+
# Micro::Case including the class 8.008k i/100ms
|
1313
|
+
# Micro::Case::Result#| 17.151k i/100ms
|
1314
|
+
# Micro::Case::Result#then 14.121k i/100ms
|
1297
1315
|
|
1298
1316
|
# Calculating -------------------------------------
|
1299
|
-
# Interactor::Organizer
|
1300
|
-
#
|
1301
|
-
# Micro::
|
1302
|
-
#
|
1303
|
-
# Micro::
|
1304
|
-
#
|
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
|
1317
|
+
# Interactor::Organizer 22.467k (± 1.8%) i/s - 112.476k in 5.007787s
|
1318
|
+
# Micro::Cases.flow([]) 133.183k (± 1.5%) i/s - 671.058k in 5.039815s
|
1319
|
+
# Micro::Case flow in a class 84.083k (± 1.8%) i/s - 428.400k in 5.096623s
|
1320
|
+
# Micro::Case including the class 80.574k (± 1.6%) i/s - 408.408k in 5.070029s
|
1321
|
+
# Micro::Case::Result#| 172.734k (± 1.1%) i/s - 874.701k in 5.064429s
|
1322
|
+
# Micro::Case::Result#then 139.799k (± 1.7%) i/s - 706.050k in 5.052035s
|
1311
1323
|
|
1312
1324
|
# Comparison:
|
1313
|
-
# Micro::Case
|
1314
|
-
# Micro::Case
|
1315
|
-
# Micro::
|
1316
|
-
# Micro::
|
1317
|
-
# Micro::
|
1318
|
-
# Interactor::Organizer:
|
1325
|
+
# Micro::Case::Result#|: 172734.4 i/s
|
1326
|
+
# Micro::Case::Result#then: 139799.0 i/s - 1.24x (± 0.00) slower
|
1327
|
+
# Micro::Cases.flow([]): 133182.9 i/s - 1.30x (± 0.00) slower
|
1328
|
+
# Micro::Case flow in a class: 84082.6 i/s - 2.05x (± 0.00) slower
|
1329
|
+
# Micro::Case including the class: 80574.3 i/s - 2.14x (± 0.00) slower
|
1330
|
+
# Interactor::Organizer: 22467.4 i/s - 7.69x (± 0.00) slower
|
1319
1331
|
```
|
1320
1332
|
</details>
|
1321
1333
|
|
@@ -1324,43 +1336,72 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_r
|
|
1324
1336
|
|
1325
1337
|
```ruby
|
1326
1338
|
# Warming up --------------------------------------
|
1327
|
-
# Interactor::Organizer
|
1328
|
-
#
|
1329
|
-
# Micro::
|
1330
|
-
#
|
1331
|
-
# Micro::
|
1332
|
-
#
|
1333
|
-
|
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
|
1339
|
+
# Interactor::Organizer 2.167k i/100ms
|
1340
|
+
# Micro::Cases.flow([]) 11.797k i/100ms
|
1341
|
+
# Micro::Case flow in a class 7.783k i/100ms
|
1342
|
+
# Micro::Case including the class 7.097k i/100ms
|
1343
|
+
# Micro::Case::Result#| 14.398k i/100ms
|
1344
|
+
# Micro::Case::Result#then 12.719k i/100ms
|
1345
|
+
|
1339
1346
|
# Calculating -------------------------------------
|
1340
|
-
# Interactor::Organizer
|
1341
|
-
#
|
1342
|
-
# Micro::
|
1343
|
-
#
|
1344
|
-
# Micro::
|
1345
|
-
#
|
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
|
1347
|
+
# Interactor::Organizer 21.863k (± 2.5%) i/s - 110.517k in 5.058420s
|
1348
|
+
# Micro::Cases.flow([]) 118.124k (± 1.8%) i/s - 601.647k in 5.095102s
|
1349
|
+
# Micro::Case flow in a class 77.801k (± 1.5%) i/s - 389.150k in 5.003002s
|
1350
|
+
# Micro::Case including the class 73.533k (± 2.1%) i/s - 369.044k in 5.021076s
|
1351
|
+
# Micro::Case::Result#| 153.746k (± 1.5%) i/s - 777.492k in 5.058177s
|
1352
|
+
# Micro::Case::Result#then 126.897k (± 1.7%) i/s - 635.950k in 5.013059s
|
1352
1353
|
|
1353
1354
|
# Comparison:
|
1354
|
-
# Micro::Case
|
1355
|
-
# Micro::Case
|
1356
|
-
# Micro::
|
1357
|
-
# Micro::
|
1358
|
-
# Micro::
|
1359
|
-
# Interactor::Organizer:
|
1355
|
+
# Micro::Case::Result#|: 153745.6 i/s
|
1356
|
+
# Micro::Case::Result#then: 126896.6 i/s - 1.21x (± 0.00) slower
|
1357
|
+
# Micro::Cases.flow([]): 118123.9 i/s - 1.30x (± 0.00) slower
|
1358
|
+
# Micro::Case flow in a class: 77800.7 i/s - 1.98x (± 0.00) slower
|
1359
|
+
# Micro::Case including the class: 73532.9 i/s - 2.09x (± 0.00) slower
|
1360
|
+
# Interactor::Organizer: 21862.9 i/s - 7.03x (± 0.00) slower
|
1360
1361
|
```
|
1361
1362
|
</details>
|
1362
1363
|
|
1363
|
-
https://github.com/serradura/u-case/
|
1364
|
+
https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/flow/
|
1365
|
+
|
1366
|
+
[⬆️ Back to Top](#table-of-contents-)
|
1367
|
+
|
1368
|
+
### Running the benchmarks
|
1369
|
+
|
1370
|
+
#### Performance (Benchmarks IPS)
|
1371
|
+
|
1372
|
+
Clone this repo and access its folder, then run the commands below:
|
1373
|
+
|
1374
|
+
**Use cases**
|
1375
|
+
|
1376
|
+
```sh
|
1377
|
+
ruby benchmarks/perfomance/use_case/failure_results.rb
|
1378
|
+
ruby benchmarks/perfomance/use_case/success_results.rb
|
1379
|
+
```
|
1380
|
+
|
1381
|
+
**Flows**
|
1382
|
+
|
1383
|
+
```sh
|
1384
|
+
ruby benchmarks/perfomance/flow/failure_results.rb
|
1385
|
+
ruby benchmarks/perfomance/flow/success_results.rb
|
1386
|
+
```
|
1387
|
+
|
1388
|
+
#### Memory profiling
|
1389
|
+
|
1390
|
+
**Use cases**
|
1391
|
+
|
1392
|
+
```sh
|
1393
|
+
./benchmarks/memory/use_case/success/with_transitions/analyze.sh
|
1394
|
+
./benchmarks/memory/use_case/success/without_transitions/analyze.sh
|
1395
|
+
```
|
1396
|
+
|
1397
|
+
**Flows**
|
1398
|
+
|
1399
|
+
```sh
|
1400
|
+
./benchmarks/memory/flow/success/with_transitions/analyze.sh
|
1401
|
+
./benchmarks/memory/flow/success/without_transitions/analyze.sh
|
1402
|
+
```
|
1403
|
+
|
1404
|
+
[⬆️ Back to Top](#table-of-contents-)
|
1364
1405
|
|
1365
1406
|
### Comparisons
|
1366
1407
|
|