From 6770d8f1b066908e5fb7401860fd6455df961281 Mon Sep 17 00:00:00 2001 From: Vladimir Dementyev Date: Tue, 3 Mar 2020 18:45:57 -0500 Subject: Add pattern matching with arrays benchmark --- benchmark/pm_array.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 benchmark/pm_array.yml (limited to 'benchmark') diff --git a/benchmark/pm_array.yml b/benchmark/pm_array.yml new file mode 100644 index 0000000000..babb65a289 --- /dev/null +++ b/benchmark/pm_array.yml @@ -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") -- cgit v1.2.3