SK
Size: a a a
SK
VP
VP
SK
D
D
"1:2:3:4:5"
допустим, вытащить "5"D
"1:2:3:4:5"
.rsplit(":", 1)[1]D
Z
D
D
D
SK
D
"1:2:3:4:5"
допустим, вытащить "5"["1:2:3:4" , "5"]
SK
["1:2:3:4" , "5"]
P
SS
f
ŹR
ŹR
big_string = Enum.join(1..100000, ":")
Benchee.run(%{
"enum_-1" => fn -> big_string |> String.split(":") |> Enum.at(-1) end,
"reverse" => fn -> big_string |> String.reverse() |> String.split(":", parts: 2) |> hd() |> String.reverse() end
})
Benchmarking enum_-1...
Benchmarking reverse...
Name ips average deviation median 99th %
enum_-1 124.29 8.05 ms ±26.80% 6.97 ms 14.04 ms
reverse 3.93 254.60 ms ±1.30% 253.82 ms 267.72 ms
Comparison:
enum_-1 124.29
reverse 3.93 - 31.65x slower +246.56 ms