ruby-changes:61952
From: Vladimir <ko1@a...>
Date: Sat, 27 Jun 2020 13:51:19 +0900 (JST)
Subject: [ruby-changes:61952] 6770d8f1b0 (master): Add pattern matching with arrays benchmark
https://git.ruby-lang.org/ruby.git/commit/?id=6770d8f1b0 From 6770d8f1b066908e5fb7401860fd6455df961281 Mon Sep 17 00:00:00 2001 From: Vladimir Dementyev <dementiev.vm@g...> Date: Tue, 3 Mar 2020 18:45:57 -0500 Subject: Add pattern matching with arrays benchmark diff --git a/benchmark/pm_array.yml b/benchmark/pm_array.yml new file mode 100644 index 0000000..babb65a --- /dev/null +++ b/benchmark/pm_array.yml @@ -0,0 +1,19 @@ https://github.com/ruby/ruby/blob/trunk/benchmark/pm_array.yml#L1 +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") -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/