mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add pattern matching with arrays benchmark
This commit is contained in:
parent
d6c9c014e2
commit
6770d8f1b0
Notes:
git
2020-06-27 13:51:28 +09:00
1 changed files with 19 additions and 0 deletions
19
benchmark/pm_array.yml
Normal file
19
benchmark/pm_array.yml
Normal file
|
@ -0,0 +1,19 @@
|
|||
prelude: |
|
||||
def call(*val)
|
||||
case val
|
||||
in [String => body]
|
||||
[200, {}, [body]]
|
||||
in [Integer => status]
|
||||
[status, {}, [""]]
|
||||
in [Integer, String] => response
|
||||
[response[0], {}, [response[1]]]
|
||||
in [Integer, Hash, String] => response
|
||||
[response[0], response[1], [response[2]]]
|
||||
end
|
||||
end
|
||||
|
||||
benchmark:
|
||||
first_match: call("ok")
|
||||
second_match: call(401)
|
||||
third_match: call(200, "ok")
|
||||
fourth_match: call(201, {}, "created")
|
Loading…
Reference in a new issue