u-case 3.1.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.sh +30 -10
- data/Gemfile +20 -9
- data/README.md +160 -134
- data/README.pt-BR.md +161 -136
- data/lib/micro/case.rb +68 -15
- data/lib/micro/case/error.rb +4 -1
- data/lib/micro/case/result.rb +42 -8
- data/lib/micro/case/result/transitions.rb +1 -4
- data/lib/micro/case/result/wrapper.rb +45 -0
- data/lib/micro/case/safe.rb +1 -1
- data/lib/micro/case/strict.rb +2 -2
- data/lib/micro/case/utils.rb +19 -10
- data/lib/micro/case/version.rb +1 -1
- data/lib/micro/cases.rb +7 -0
- data/lib/micro/cases/error.rb +13 -0
- data/lib/micro/cases/flow.rb +23 -14
- 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 +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9b498ae868d7b556a8a0e3a35c314e4704e206c8708b195d585bef6a7766b8b
|
4
|
+
data.tar.gz: 699ee398f8757ffa406ee1fd86e5d54fa757c7a79d30b73e8af86ba51a65f233
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b869538c2bff9f728f3dccee9f1be07bd68d47746dae078394e393962a4b29fe881d1909bd574d19ca0ebf82eddb1951932e29cf92aeed00975a73a61b53cb3b
|
7
|
+
data.tar.gz: 7adc5bf983cdbb9e1ce4cb0eea5ab985ab0df4889ccc43545585381695d5163ec4ca139b7399e41399e736a4989923b3992aece149a6126e6315f9db760a19d0
|
data/.travis.sh
CHANGED
@@ -2,22 +2,42 @@
|
|
2
2
|
|
3
3
|
ruby_v=$(ruby -v)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
ACTIVERECORD_VERSION='3.2' bundle update
|
6
|
+
ACTIVERECORD_VERSION='3.2' ENABLE_TRANSITIONS='true' bundle exec rake test
|
7
|
+
ACTIVERECORD_VERSION='3.2' ENABLE_TRANSITIONS='false' bundle exec rake test
|
8
|
+
|
9
|
+
ACTIVERECORD_VERSION='4.0' bundle update
|
10
|
+
ACTIVERECORD_VERSION='4.0' ENABLE_TRANSITIONS='true' bundle exec rake test
|
11
|
+
ACTIVERECORD_VERSION='4.0' ENABLE_TRANSITIONS='false' bundle exec rake test
|
12
|
+
|
13
|
+
ACTIVERECORD_VERSION='4.1' bundle update
|
14
|
+
ACTIVERECORD_VERSION='4.1' ENABLE_TRANSITIONS='true' bundle exec rake test
|
15
|
+
ACTIVERECORD_VERSION='4.1' ENABLE_TRANSITIONS='false' bundle exec rake test
|
16
|
+
|
17
|
+
ACTIVERECORD_VERSION='4.2' bundle update
|
18
|
+
ACTIVERECORD_VERSION='4.2' ENABLE_TRANSITIONS='true' bundle exec rake test
|
19
|
+
ACTIVERECORD_VERSION='4.2' ENABLE_TRANSITIONS='false' bundle exec rake test
|
20
|
+
|
21
|
+
ACTIVERECORD_VERSION='5.0' bundle update
|
22
|
+
ACTIVERECORD_VERSION='5.0' ENABLE_TRANSITIONS='true' bundle exec rake test
|
23
|
+
ACTIVERECORD_VERSION='5.0' ENABLE_TRANSITIONS='false' bundle exec rake test
|
24
|
+
|
25
|
+
ACTIVERECORD_VERSION='5.1' bundle update
|
26
|
+
ACTIVERECORD_VERSION='5.1' ENABLE_TRANSITIONS='true' bundle exec rake test
|
27
|
+
ACTIVERECORD_VERSION='5.1' ENABLE_TRANSITIONS='false' bundle exec rake test
|
8
28
|
|
9
29
|
if [[ ! $ruby_v =~ '2.2.0' ]]; then
|
10
|
-
|
11
|
-
|
12
|
-
|
30
|
+
ACTIVERECORD_VERSION='5.2' bundle update
|
31
|
+
ACTIVERECORD_VERSION='5.2' ENABLE_TRANSITIONS='true' bundle exec rake test
|
32
|
+
ACTIVERECORD_VERSION='5.2' ENABLE_TRANSITIONS='false' bundle exec rake test
|
13
33
|
fi
|
14
34
|
|
15
35
|
if [[ $ruby_v =~ '2.5.' ]] || [[ $ruby_v =~ '2.6.' ]] || [[ $ruby_v =~ '2.7.' ]]; then
|
16
|
-
|
17
|
-
|
18
|
-
|
36
|
+
ACTIVERECORD_VERSION='6.0' bundle update
|
37
|
+
ACTIVERECORD_VERSION='6.0' ENABLE_TRANSITIONS='true' bundle exec rake test
|
38
|
+
ACTIVERECORD_VERSION='6.0' ENABLE_TRANSITIONS='false' bundle exec rake test
|
19
39
|
fi
|
20
40
|
|
21
41
|
bundle update
|
22
|
-
ENABLE_TRANSITIONS='false' bundle exec rake test
|
23
42
|
ENABLE_TRANSITIONS='true' bundle exec rake test
|
43
|
+
ENABLE_TRANSITIONS='false' bundle exec rake test
|
data/Gemfile
CHANGED
@@ -2,19 +2,19 @@ source "https://rubygems.org"
|
|
2
2
|
|
3
3
|
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
4
|
|
5
|
-
|
5
|
+
activerecord_version = ENV.fetch('ACTIVERECORD_VERSION', '6.1')
|
6
6
|
|
7
|
-
|
7
|
+
activerecord = case activerecord_version
|
8
8
|
when '3.2' then '3.2.22'
|
9
|
+
when '4.0' then '4.0.13'
|
10
|
+
when '4.1' then '4.1.16'
|
11
|
+
when '4.2' then '4.2.11'
|
12
|
+
when '5.0' then '5.0.7'
|
13
|
+
when '5.1' then '5.1.7'
|
9
14
|
when '5.2' then '5.2.3'
|
10
|
-
when '6.0' then '6.0.
|
15
|
+
when '6.0' then '6.0.3'
|
11
16
|
end
|
12
17
|
|
13
|
-
if activemodel_version < '6.1.0'
|
14
|
-
gem 'activemodel', activemodel, require: false
|
15
|
-
gem 'activesupport', activemodel, require: false
|
16
|
-
end
|
17
|
-
|
18
18
|
simplecov_version =
|
19
19
|
case RUBY_VERSION
|
20
20
|
when /\A2.[23]/ then '~> 0.17.1'
|
@@ -23,9 +23,20 @@ simplecov_version =
|
|
23
23
|
end
|
24
24
|
|
25
25
|
group :test do
|
26
|
-
gem 'minitest',
|
26
|
+
gem 'minitest', activerecord_version < '4.1' ? '~> 4.2' : '~> 5.0'
|
27
27
|
|
28
28
|
gem 'simplecov', simplecov_version, require: false
|
29
|
+
|
30
|
+
if activerecord
|
31
|
+
sqlite3 =
|
32
|
+
case activerecord
|
33
|
+
when /\A6\.0/, nil then '~> 1.4.0'
|
34
|
+
else '~> 1.3.0'
|
35
|
+
end
|
36
|
+
|
37
|
+
gem 'sqlite3', sqlite3
|
38
|
+
gem 'activerecord', activerecord, require: 'active_record'
|
39
|
+
end
|
29
40
|
end
|
30
41
|
|
31
42
|
pry_byebug_version =
|
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
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
|
|
8
8
|
<p align="center">
|
9
|
-
<img src="https://img.shields.io/badge/ruby
|
9
|
+
<img src="https://img.shields.io/badge/ruby->%3D%202.2.0-ruby.svg?colorA=99004d&colorB=cc0066" alt="Ruby">
|
10
10
|
|
11
11
|
<a href="https://rubygems.org/gems/u-case">
|
12
12
|
<img alt="Gem" src="https://img.shields.io/gem/v/u-case.svg?style=flat-square">
|
@@ -38,11 +38,13 @@ The main project goals are:
|
|
38
38
|
|
39
39
|
Version | Documentation
|
40
40
|
--------- | -------------
|
41
|
-
|
41
|
+
unreleased| https://github.com/serradura/u-case/blob/main/README.md
|
42
|
+
4.2.1 | https://github.com/serradura/u-case/blob/v4.x/README.md
|
43
|
+
3.1.0 | https://github.com/serradura/u-case/blob/v3.x/README.md
|
42
44
|
2.6.0 | https://github.com/serradura/u-case/blob/v2.x/README.md
|
43
45
|
1.1.0 | https://github.com/serradura/u-case/blob/v1.x/README.md
|
44
46
|
|
45
|
-
> **Note:** Você entende português?
|
47
|
+
> **Note:** Você entende português? 🇧🇷 🇵🇹 Verifique o [README traduzido em pt-BR](https://github.com/serradura/u-case/blob/main/README.pt-BR.md).
|
46
48
|
|
47
49
|
## Table of Contents <!-- omit in toc -->
|
48
50
|
- [Compatibility](#compatibility)
|
@@ -81,6 +83,9 @@ Version | Documentation
|
|
81
83
|
- [Success results](#success-results)
|
82
84
|
- [Failure results](#failure-results)
|
83
85
|
- [`Micro::Cases::Flow`](#microcasesflow)
|
86
|
+
- [Running the benchmarks](#running-the-benchmarks)
|
87
|
+
- [Performance (Benchmarks IPS)](#performance-benchmarks-ips)
|
88
|
+
- [Memory profiling](#memory-profiling)
|
84
89
|
- [Comparisons](#comparisons)
|
85
90
|
- [Examples](#examples)
|
86
91
|
- [1️⃣ Users creation](#1️⃣-users-creation)
|
@@ -94,11 +99,13 @@ Version | Documentation
|
|
94
99
|
|
95
100
|
## Compatibility
|
96
101
|
|
97
|
-
| u-case | branch | ruby | activemodel |
|
98
|
-
| -------------- | ------- | -------- | ------------- |
|
99
|
-
|
|
100
|
-
| 2.
|
101
|
-
|
|
102
|
+
| u-case | branch | ruby | activemodel | u-attributes |
|
103
|
+
| -------------- | ------- | -------- | ------------- | ------------ |
|
104
|
+
| unreleased | main | >= 2.2.0 | >= 3.2, < 6.1 | ~> 2.0 |
|
105
|
+
| 4.2.1 | v4.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 2.0 |
|
106
|
+
| 3.1.0 | v3.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
|
107
|
+
| 2.6.0 | v2.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
|
108
|
+
| 1.1.0 | v1.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
|
102
109
|
|
103
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.
|
104
111
|
|
@@ -119,7 +126,7 @@ Version | Documentation
|
|
119
126
|
Add this line to your application's Gemfile:
|
120
127
|
|
121
128
|
```ruby
|
122
|
-
gem 'u-case', '~>
|
129
|
+
gem 'u-case', '~> 4.1.0'
|
123
130
|
```
|
124
131
|
|
125
132
|
And then execute:
|
@@ -128,7 +135,7 @@ And then execute:
|
|
128
135
|
|
129
136
|
Or install it yourself as:
|
130
137
|
|
131
|
-
$ gem install u-case
|
138
|
+
$ gem install u-case
|
132
139
|
|
133
140
|
## Usage
|
134
141
|
|
@@ -1193,104 +1200,106 @@ end
|
|
1193
1200
|
|
1194
1201
|
| Gem / Abstraction | Iterations per second | Comparison |
|
1195
1202
|
| ----------------- | --------------------: | ----------------: |
|
1196
|
-
| Dry::Monads |
|
1197
|
-
| **Micro::Case** |
|
1198
|
-
| Interactor |
|
1199
|
-
| Trailblazer::Operation |
|
1200
|
-
| Dry::Transaction |
|
1203
|
+
| Dry::Monads | 315635.1 | _**The Fastest**_ |
|
1204
|
+
| **Micro::Case** | 75837.7 | 4.16x slower |
|
1205
|
+
| Interactor | 59745.5 | 5.28x slower |
|
1206
|
+
| Trailblazer::Operation | 28423.9 | 11.10x slower |
|
1207
|
+
| Dry::Transaction | 10130.9 | 31.16x slower |
|
1201
1208
|
|
1202
1209
|
<details>
|
1203
1210
|
<summary>Show the full <a href="https://github.com/evanphx/benchmark-ips">benchmark/ips</a> results.</summary>
|
1204
1211
|
|
1205
1212
|
```ruby
|
1206
1213
|
# Warming up --------------------------------------
|
1207
|
-
# Interactor
|
1208
|
-
# Trailblazer::Operation
|
1209
|
-
#
|
1210
|
-
#
|
1211
|
-
#
|
1212
|
-
#
|
1213
|
-
# Micro::Case::Safe
|
1214
|
+
# Interactor 5.711k i/100ms
|
1215
|
+
# Trailblazer::Operation
|
1216
|
+
# 2.283k i/100ms
|
1217
|
+
# Dry::Monads 31.130k i/100ms
|
1218
|
+
# Dry::Transaction 994.000 i/100ms
|
1219
|
+
# Micro::Case 7.911k i/100ms
|
1220
|
+
# Micro::Case::Safe 7.911k i/100ms
|
1221
|
+
# Micro::Case::Strict 6.248k i/100ms
|
1214
1222
|
|
1215
1223
|
# Calculating -------------------------------------
|
1216
|
-
# Interactor
|
1217
|
-
# Trailblazer::Operation
|
1218
|
-
#
|
1219
|
-
#
|
1220
|
-
#
|
1221
|
-
#
|
1222
|
-
# Micro::Case::Safe
|
1224
|
+
# Interactor 59.746k (±29.9%) i/s - 274.128k in 5.049901s
|
1225
|
+
# Trailblazer::Operation
|
1226
|
+
# 28.424k (±15.8%) i/s - 141.546k in 5.087882s
|
1227
|
+
# Dry::Monads 315.635k (± 6.1%) i/s - 1.588M in 5.048914s
|
1228
|
+
# Dry::Transaction 10.131k (± 6.4%) i/s - 50.694k in 5.025150s
|
1229
|
+
# Micro::Case 75.838k (± 9.7%) i/s - 379.728k in 5.052573s
|
1230
|
+
# Micro::Case::Safe 75.461k (±10.1%) i/s - 379.728k in 5.079238s
|
1231
|
+
# Micro::Case::Strict 64.235k (± 9.0%) i/s - 324.896k in 5.097028s
|
1223
1232
|
|
1224
1233
|
# Comparison:
|
1225
|
-
# Dry::Monads:
|
1226
|
-
# Micro::Case:
|
1227
|
-
# Micro::Case::Safe:
|
1228
|
-
# Micro::Case::Strict:
|
1229
|
-
# Interactor:
|
1230
|
-
# Trailblazer::Operation:
|
1231
|
-
# Dry::Transaction:
|
1234
|
+
# Dry::Monads: 315635.1 i/s
|
1235
|
+
# Micro::Case: 75837.7 i/s - 4.16x (± 0.00) slower
|
1236
|
+
# Micro::Case::Safe: 75461.3 i/s - 4.18x (± 0.00) slower
|
1237
|
+
# Micro::Case::Strict: 64234.9 i/s - 4.91x (± 0.00) slower
|
1238
|
+
# Interactor: 59745.5 i/s - 5.28x (± 0.00) slower
|
1239
|
+
# Trailblazer::Operation: 28423.9 i/s - 11.10x (± 0.00) slower
|
1240
|
+
# Dry::Transaction: 10130.9 i/s - 31.16x (± 0.00) slower
|
1232
1241
|
```
|
1233
1242
|
</details>
|
1234
1243
|
|
1235
|
-
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.rb
|
1236
1245
|
|
1237
1246
|
#### Failure results
|
1238
1247
|
|
1239
1248
|
| Gem / Abstraction | Iterations per second | Comparison |
|
1240
1249
|
| ----------------- | --------------------: | ----------------: |
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
| Trailblazer::Operation |
|
1244
|
-
| Interactor |
|
1245
|
-
| Dry::Transaction |
|
1250
|
+
| Dry::Monads | 135386.9 | _**The Fastest**_ |
|
1251
|
+
| **Micro::Case** | 73489.3 | 1.85x slower |
|
1252
|
+
| Trailblazer::Operation | 29016.4 | 4.67x slower |
|
1253
|
+
| Interactor | 27037.0 | 5.01x slower |
|
1254
|
+
| Dry::Transaction | 8988.6 | 15.06x slower |
|
1246
1255
|
|
1247
1256
|
<details>
|
1248
1257
|
<summary>Show the full <a href="https://github.com/evanphx/benchmark-ips">benchmark/ips</a> results.</summary>
|
1249
1258
|
|
1250
1259
|
```ruby
|
1251
1260
|
# Warming up --------------------------------------
|
1252
|
-
# Interactor
|
1253
|
-
# Trailblazer::Operation
|
1254
|
-
# Dry::Monads
|
1255
|
-
# Dry::Transaction
|
1256
|
-
# Micro::Case
|
1257
|
-
#
|
1258
|
-
#
|
1261
|
+
# Interactor 2.626k i/100ms
|
1262
|
+
# Trailblazer::Operation 2.343k i/100ms
|
1263
|
+
# Dry::Monads 13.386k i/100ms
|
1264
|
+
# Dry::Transaction 868.000 i/100ms
|
1265
|
+
# Micro::Case 7.603k i/100ms
|
1266
|
+
# Micro::Case::Safe 7.598k i/100ms
|
1267
|
+
# Micro::Case::Strict 6.178k i/100ms
|
1259
1268
|
|
1260
1269
|
# Calculating -------------------------------------
|
1261
|
-
# Interactor
|
1262
|
-
# Trailblazer::Operation
|
1263
|
-
# Dry::Monads
|
1264
|
-
# Dry::Transaction
|
1265
|
-
# Micro::Case
|
1266
|
-
#
|
1267
|
-
#
|
1270
|
+
# Interactor 27.037k (±24.9%) i/s - 128.674k in 5.102133s
|
1271
|
+
# Trailblazer::Operation 29.016k (±12.4%) i/s - 145.266k in 5.074991s
|
1272
|
+
# Dry::Monads 135.387k (±15.1%) i/s - 669.300k in 5.055356s
|
1273
|
+
# Dry::Transaction 8.989k (± 9.2%) i/s - 45.136k in 5.084820s
|
1274
|
+
# Micro::Case 73.247k (± 9.9%) i/s - 364.944k in 5.030449s
|
1275
|
+
# Micro::Case::Safe 73.489k (± 9.6%) i/s - 364.704k in 5.007282s
|
1276
|
+
# Micro::Case::Strict 61.980k (± 8.0%) i/s - 308.900k in 5.014821s
|
1268
1277
|
|
1269
1278
|
# Comparison:
|
1270
|
-
#
|
1271
|
-
# Micro::Case::Safe:
|
1272
|
-
#
|
1273
|
-
#
|
1274
|
-
# Trailblazer::Operation:
|
1275
|
-
# Interactor:
|
1276
|
-
# Dry::Transaction:
|
1279
|
+
# Dry::Monads: 135386.9 i/s
|
1280
|
+
# Micro::Case::Safe: 73489.3 i/s - 1.84x (± 0.00) slower
|
1281
|
+
# Micro::Case: 73246.6 i/s - 1.85x (± 0.00) slower
|
1282
|
+
# Micro::Case::Strict: 61979.7 i/s - 2.18x (± 0.00) slower
|
1283
|
+
# Trailblazer::Operation: 29016.4 i/s - 4.67x (± 0.00) slower
|
1284
|
+
# Interactor: 27037.0 i/s - 5.01x (± 0.00) slower
|
1285
|
+
# Dry::Transaction: 8988.6 i/s - 15.06x (± 0.00) slower
|
1277
1286
|
```
|
1278
1287
|
</details>
|
1279
1288
|
|
1280
|
-
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.rb
|
1281
1290
|
|
1282
1291
|
---
|
1283
1292
|
|
1284
1293
|
### `Micro::Cases::Flow`
|
1285
1294
|
|
1286
|
-
| Gems / Abstraction | [Success results](https://github.com/serradura/u-case/blob/main/benchmarks/flow/
|
1295
|
+
| Gems / Abstraction | [Success results](https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/flow/success_results.rb) | [Failure results](https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/flow/failure_results.rb) |
|
1287
1296
|
| ------------------------------------------- | ----------------: | ----------------: |
|
1288
|
-
| Micro::Case
|
1289
|
-
| Micro::Case
|
1290
|
-
| Micro::
|
1291
|
-
| Micro::
|
1292
|
-
| Micro::
|
1293
|
-
| Interactor::Organizer |
|
1297
|
+
| Micro::Case::Result `pipe` method | 80936.2 i/s | 78280.4 i/s |
|
1298
|
+
| Micro::Case::Result `then` method | 0x slower | 0x slower |
|
1299
|
+
| Micro::Cases.flow | 0x slower | 0x slower |
|
1300
|
+
| Micro::Case class with an inner flow | 1.72x slower | 1.68x slower |
|
1301
|
+
| Micro::Case class including itself as a step| 1.93x slower | 1.87x slower |
|
1302
|
+
| Interactor::Organizer | 3.33x slower | 3.22x slower |
|
1294
1303
|
|
1295
1304
|
\* The `Dry::Monads`, `Dry::Transaction`, `Trailblazer::Operation` gems are out of this analysis because all of them doesn't have this kind of feature.
|
1296
1305
|
|
@@ -1299,40 +1308,28 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_r
|
|
1299
1308
|
|
1300
1309
|
```ruby
|
1301
1310
|
# 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
|
1311
|
+
# Interactor::Organizer 1.809k i/100ms
|
1312
|
+
# Micro::Cases.flow([]) 7.808k i/100ms
|
1313
|
+
# Micro::Case flow in a class 4.816k i/100ms
|
1314
|
+
# Micro::Case including the class 4.094k i/100ms
|
1315
|
+
# Micro::Case::Result#| 7.656k i/100ms
|
1316
|
+
# Micro::Case::Result#then 7.138k i/100ms
|
1314
1317
|
|
1315
1318
|
# 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
|
1319
|
+
# Interactor::Organizer 24.290k (±24.0%) i/s - 113.967k in 5.032825s
|
1320
|
+
# Micro::Cases.flow([]) 74.790k (±11.1%) i/s - 374.784k in 5.071740s
|
1321
|
+
# Micro::Case flow in a class 47.043k (± 8.0%) i/s - 235.984k in 5.047477s
|
1322
|
+
# Micro::Case including the class 42.030k (± 8.5%) i/s - 208.794k in 5.002138s
|
1323
|
+
# Micro::Case::Result#| 80.936k (±15.9%) i/s - 398.112k in 5.052531s
|
1324
|
+
# Micro::Case::Result#then 71.459k (± 8.8%) i/s - 356.900k in 5.030526s
|
1328
1325
|
|
1329
1326
|
# Comparison:
|
1330
|
-
# Micro::Case
|
1331
|
-
# Micro::
|
1332
|
-
# Micro::Case
|
1333
|
-
# Micro::
|
1334
|
-
# Micro::
|
1335
|
-
# Interactor::Organizer:
|
1327
|
+
# Micro::Case::Result#|: 80936.2 i/s
|
1328
|
+
# Micro::Cases.flow([]): 74790.1 i/s - same-ish: difference falls within error
|
1329
|
+
# Micro::Case::Result#then: 71459.5 i/s - same-ish: difference falls within error
|
1330
|
+
# Micro::Case flow in a class: 47042.6 i/s - 1.72x (± 0.00) slower
|
1331
|
+
# Micro::Case including the class: 42030.2 i/s - 1.93x (± 0.00) slower
|
1332
|
+
# Interactor::Organizer: 24290.3 i/s - 3.33x (± 0.00) slower
|
1336
1333
|
```
|
1337
1334
|
</details>
|
1338
1335
|
|
@@ -1341,43 +1338,72 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_r
|
|
1341
1338
|
|
1342
1339
|
```ruby
|
1343
1340
|
# 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
|
1341
|
+
# Interactor::Organizer 1.734k i/100ms
|
1342
|
+
# Micro::Cases.flow([]) 7.515k i/100ms
|
1343
|
+
# Micro::Case flow in a class 4.636k i/100ms
|
1344
|
+
# Micro::Case including the class 4.114k i/100ms
|
1345
|
+
# Micro::Case::Result#| 7.588k i/100ms
|
1346
|
+
# Micro::Case::Result#then 6.681k i/100ms
|
1347
|
+
|
1356
1348
|
# 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
|
1349
|
+
# Interactor::Organizer 24.280k (±24.5%) i/s - 112.710k in 5.013334s
|
1350
|
+
# Micro::Cases.flow([]) 74.999k (± 9.8%) i/s - 375.750k in 5.055777s
|
1351
|
+
# Micro::Case flow in a class 46.681k (± 9.3%) i/s - 236.436k in 5.105105s
|
1352
|
+
# Micro::Case including the class 41.921k (± 8.9%) i/s - 209.814k in 5.043622s
|
1353
|
+
# Micro::Case::Result#| 78.280k (±12.6%) i/s - 386.988k in 5.022146s
|
1354
|
+
# Micro::Case::Result#then 68.898k (± 8.8%) i/s - 347.412k in 5.080116s
|
1369
1355
|
|
1370
1356
|
# Comparison:
|
1371
|
-
# Micro::Case
|
1372
|
-
# Micro::
|
1373
|
-
# Micro::Case
|
1374
|
-
# Micro::
|
1375
|
-
# Micro::
|
1376
|
-
# Interactor::Organizer:
|
1357
|
+
# Micro::Case::Result#|: 78280.4 i/s
|
1358
|
+
# Micro::Cases.flow([]): 74999.4 i/s - same-ish: difference falls within error
|
1359
|
+
# Micro::Case::Result#then: 68898.4 i/s - same-ish: difference falls within error
|
1360
|
+
# Micro::Case flow in a class: 46681.0 i/s - 1.68x (± 0.00) slower
|
1361
|
+
# Micro::Case including the class: 41920.8 i/s - 1.87x (± 0.00) slower
|
1362
|
+
# Interactor::Organizer: 24280.0 i/s - 3.22x (± 0.00) slower
|
1377
1363
|
```
|
1378
1364
|
</details>
|
1379
1365
|
|
1380
|
-
https://github.com/serradura/u-case/
|
1366
|
+
https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/flow/
|
1367
|
+
|
1368
|
+
[⬆️ Back to Top](#table-of-contents-)
|
1369
|
+
|
1370
|
+
### Running the benchmarks
|
1371
|
+
|
1372
|
+
#### Performance (Benchmarks IPS)
|
1373
|
+
|
1374
|
+
Clone this repo and access its folder, then run the commands below:
|
1375
|
+
|
1376
|
+
**Use cases**
|
1377
|
+
|
1378
|
+
```sh
|
1379
|
+
ruby benchmarks/perfomance/use_case/failure_results.rb
|
1380
|
+
ruby benchmarks/perfomance/use_case/success_results.rb
|
1381
|
+
```
|
1382
|
+
|
1383
|
+
**Flows**
|
1384
|
+
|
1385
|
+
```sh
|
1386
|
+
ruby benchmarks/perfomance/flow/failure_results.rb
|
1387
|
+
ruby benchmarks/perfomance/flow/success_results.rb
|
1388
|
+
```
|
1389
|
+
|
1390
|
+
#### Memory profiling
|
1391
|
+
|
1392
|
+
**Use cases**
|
1393
|
+
|
1394
|
+
```sh
|
1395
|
+
./benchmarks/memory/use_case/success/with_transitions/analyze.sh
|
1396
|
+
./benchmarks/memory/use_case/success/without_transitions/analyze.sh
|
1397
|
+
```
|
1398
|
+
|
1399
|
+
**Flows**
|
1400
|
+
|
1401
|
+
```sh
|
1402
|
+
./benchmarks/memory/flow/success/with_transitions/analyze.sh
|
1403
|
+
./benchmarks/memory/flow/success/without_transitions/analyze.sh
|
1404
|
+
```
|
1405
|
+
|
1406
|
+
[⬆️ Back to Top](#table-of-contents-)
|
1381
1407
|
|
1382
1408
|
### Comparisons
|
1383
1409
|
|