Last active
July 16, 2016 12:48
-
-
Save eksperimental/e7cda7722d42e43c4c2f69825149c7df to your computer and use it in GitHub Desktop.
Enum.slice rewrite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Data do | |
@slice_counts [0, 1, 100, 990, ] | |
@terms [ | |
:range, :range_single, :range_big, :range_huge, | |
:list, :list_empty, :list_single, :list_big, :list_huge, | |
:map, :map_empty, :map_single, :map_big, :map_huge, | |
:struct, :struct_empty, :struct_single, :struct_big, :struct_huge, | |
] | |
@range -499..500 | |
@range_single 0..0 | |
@range_big -49_999..50_000 | |
@range_huge -249_999..250_000 | |
@list @range |> Enum.to_list | |
@list_empty [] | |
@list_single [1] | |
@list_big @range_big |> Enum.to_list | |
@list_huge @range_huge |> Enum.to_list | |
@map @list |> Enum.map(fn(v) -> {v, v} end) |> Enum.into(%{}) | |
@map_empty %{} | |
@map_single %{1 => 1} | |
@map_big @list_big |> Enum.map(fn(v) -> {v, v} end) |> Enum.into(%{}) | |
@map_huge @list_huge |> Enum.map(fn(v) -> {v, v} end) |> Enum.into(%{}) | |
@struct MapSet.new(@list) | |
@struct_empty MapSet.new | |
@struct_single MapSet.new(@list_single) | |
@struct_big MapSet.new(@list_big) | |
@struct_huge MapSet.new(@list_huge) | |
def get_module, | |
do: [System.get_env["MODULE"]] |> Module.concat | |
def terms, | |
do: @terms | |
def get_term(:range), | |
do: @range | |
def get_term(:range_single), | |
do: @range_single | |
def get_term(:range_big), | |
do: @range_big | |
def get_term(:range_huge), | |
do: @range_huge | |
def get_term(:list), | |
do: @list | |
def get_term(:list_empty), | |
do: @list_empty | |
def get_term(:list_single), | |
do: @list_single | |
def get_term(:list_big), | |
do: @list_big | |
def get_term(:list_huge), | |
do: @list_huge | |
def get_term(:map), | |
do: @map | |
def get_term(:map_empty), | |
do: @map_empty | |
def get_term(:map_single), | |
do: @map_single | |
def get_term(:map_big), | |
do: @map_big | |
def get_term(:map_huge), | |
do: @map_huge | |
def get_term(:struct), | |
do: @struct | |
def get_term(:struct_empty), | |
do: @struct_empty | |
def get_term(:struct_single), | |
do: @struct_single | |
def get_term(:struct_big), | |
do: @struct_big | |
def get_term(:struct_huge), | |
do: @struct_huge | |
def slice_counts, | |
do: @slice_counts | |
end | |
defmodule EnumFetchBench do | |
import Data | |
IO.puts "#{System.get_env["MODULE"]}.slice/3 - Elixir v#{System.build_info[:build]}" | |
for term_name <- terms(), slice_count <- slice_counts() do | |
count = Enum.count(get_term(term_name)) | |
defmodule :"#{term_name} (#{count} elem), slice_count: #{slice_count}" do | |
use Benchfella | |
@term_name term_name | |
@slice_count slice_count | |
@count count | |
@last @count - 1 | |
@middle @last |> div(2) | |
@middle_neg abs(@middle) * -1 | |
@past @count + 1_000 | |
@past_neg abs(@count + 1_000) * -1 | |
bench "first", [module: get_module(), term: get_term(@term_name)] do | |
module.slice(term, 0, @slice_count) | |
end | |
bench "first (neg index)", [module: get_module(), term: get_term(@term_name)] do | |
module.slice(term, -(@last), @slice_count) | |
end | |
bench "middle", [module: get_module(), term: get_term(@term_name)] do | |
module.slice(term, @middle, @slice_count) | |
end | |
bench "middle (neg index)", [module: get_module(), term: get_term(@term_name)] do | |
module.slice(term, @middle_neg, @slice_count) | |
end | |
bench "last", [module: get_module(), term: get_term(@term_name)] do | |
module.slice(term, @last, @slice_count) | |
end | |
bench "last (neg index)", [module: get_module(), term: get_term(@term_name)] do | |
module.slice(term, -1, @slice_count) | |
end | |
bench "out of bound", [module: get_module(), term: get_term(@term_name)] do | |
module.slice(term, @past_neg, @slice_count) | |
end | |
bench "out of bound (neg index)", [module: get_module(), term: get_term(@term_name)] do | |
module.slice(term, @past_neg, @slice_count) | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ exenv local master && | |
> MODULE=EnumSlice.Original mix bench bench/enum_slice_bench.exs -d 3 && | |
> MODULE=EnumSlice.Rewritten mix bench bench/enum_slice_bench.exs -d 3 && | |
> mix bench.cmp -d percent; bell | |
EnumSlice.Original.slice/3 - Elixir v1.4.0-dev (8b99214) | |
Settings: | |
duration: 3.0 s | |
Finished in 5711.31 seconds | |
## :"range_single (1 elem), slice_count: 0" | |
benchmark name iterations average time | |
middle (neg index) 10000000 0.40 µs/op | |
first 10000000 0.40 µs/op | |
first (neg index) 10000000 0.40 µs/op | |
middle 10000000 0.41 µs/op | |
last 10000000 0.42 µs/op | |
out of bound 10000000 0.68 µs/op | |
out of bound (neg index) 10000000 0.69 µs/op | |
last (neg index) 10000000 0.71 µs/op | |
## :"struct_huge (500000 elem), slice_count: 100" | |
benchmark name iterations average time | |
first 500 12160.24 µs/op | |
middle 100 35617.77 µs/op | |
last 100 56980.11 µs/op | |
out of bound 50 90136.48 µs/op | |
first (neg index) 50 91216.00 µs/op | |
out of bound (neg index) 50 91433.64 µs/op | |
middle (neg index) 50 95145.14 µs/op | |
last (neg index) 50 98145.58 µs/op | |
## :"range (1000 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 10000000 0.42 µs/op | |
middle 100000 49.49 µs/op | |
last 50000 99.41 µs/op | |
out of bound (neg index) 50000 150.82 µs/op | |
out of bound 50000 151.10 µs/op | |
first (neg index) 50000 152.29 µs/op | |
middle (neg index) 50000 159.44 µs/op | |
last (neg index) 50000 164.33 µs/op | |
## :"list_big (100000 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 100000000 0.09 µs/op | |
out of bound (neg index) 50000 142.66 µs/op | |
first (neg index) 50000 142.86 µs/op | |
out of bound 50000 144.08 µs/op | |
middle 10000 686.62 µs/op | |
middle (neg index) 10000 833.82 µs/op | |
last 5000 1363.74 µs/op | |
last (neg index) 5000 1566.49 µs/op | |
## :"range_big (100000 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 10000000 0.41 µs/op | |
middle 1000 4740.20 µs/op | |
last 500 9572.82 µs/op | |
out of bound (neg index) 500 15089.91 µs/op | |
out of bound 500 15102.75 µs/op | |
middle (neg index) 500 15255.80 µs/op | |
last (neg index) 500 15317.89 µs/op | |
first (neg index) 500 15318.40 µs/op | |
## :"struct_empty (0 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 100000000 0.29 µs/op | |
middle (neg index) 100000000 0.29 µs/op | |
middle 100000000 0.29 µs/op | |
first (neg index) 100000000 0.29 µs/op | |
out of bound (neg index) 10000000 0.53 µs/op | |
last (neg index) 10000000 0.53 µs/op | |
out of bound 10000000 0.53 µs/op | |
last 10000000 0.54 µs/op | |
## :"struct (1000 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 500000 20.62 µs/op | |
middle 100000 63.51 µs/op | |
last 50000 104.40 µs/op | |
last (neg index) 50000 167.08 µs/op | |
first (neg index) 50000 167.17 µs/op | |
middle (neg index) 50000 167.98 µs/op | |
out of bound (neg index) 50000 168.06 µs/op | |
out of bound 50000 168.07 µs/op | |
## :"map_big (100000 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 1000 3723.43 µs/op | |
middle 1000 7132.40 µs/op | |
last 500 13542.53 µs/op | |
out of bound 500 20282.54 µs/op | |
middle (neg index) 500 20994.53 µs/op | |
first (neg index) 500 21372.87 µs/op | |
last (neg index) 500 21863.01 µs/op | |
out of bound (neg index) 500 24508.14 µs/op | |
## :"map_single (1 elem), slice_count: 0" | |
benchmark name iterations average time | |
middle (neg index) 10000000 0.40 µs/op | |
last 10000000 0.40 µs/op | |
first 10000000 0.40 µs/op | |
first (neg index) 10000000 0.54 µs/op | |
middle 10000000 0.55 µs/op | |
last (neg index) 10000000 0.63 µs/op | |
out of bound (neg index) 10000000 0.63 µs/op | |
out of bound 10000000 0.80 µs/op | |
## :"struct (1000 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 500000 20.43 µs/op | |
middle 100000 63.11 µs/op | |
last 50000 103.60 µs/op | |
out of bound 50000 167.03 µs/op | |
out of bound (neg index) 50000 168.67 µs/op | |
first (neg index) 50000 168.84 µs/op | |
middle (neg index) 50000 174.57 µs/op | |
last (neg index) 50000 181.31 µs/op | |
## :"map_big (100000 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 1000 3011.63 µs/op | |
middle 1000 7469.46 µs/op | |
last 500 11897.11 µs/op | |
first (neg index) 500 20278.89 µs/op | |
out of bound 500 21284.65 µs/op | |
last (neg index) 500 24580.95 µs/op | |
middle (neg index) 200 29311.51 µs/op | |
out of bound (neg index) 100 30531.68 µs/op | |
## :"struct (1000 elem), slice_count: 100" | |
benchmark name iterations average time | |
first 100000 36.04 µs/op | |
middle 100000 74.59 µs/op | |
last 50000 110.77 µs/op | |
middle (neg index) 50000 184.28 µs/op | |
out of bound (neg index) 50000 195.41 µs/op | |
out of bound 50000 205.65 µs/op | |
first (neg index) 50000 212.96 µs/op | |
last (neg index) 50000 224.62 µs/op | |
## :"map_huge (500000 elem), slice_count: 100" | |
benchmark name iterations average time | |
first 500 15610.84 µs/op | |
middle 100 37513.82 µs/op | |
last 100 61745.66 µs/op | |
out of bound (neg index) 50 103338.38 µs/op | |
out of bound 50 103587.92 µs/op | |
first (neg index) 50 105947.00 µs/op | |
middle (neg index) 50 106833.64 µs/op | |
last (neg index) 50 110724.32 µs/op | |
## :"range_single (1 elem), slice_count: 990" | |
benchmark name iterations average time | |
last 10000000 0.46 µs/op | |
middle 10000000 0.47 µs/op | |
first 10000000 0.48 µs/op | |
first (neg index) 10000000 0.55 µs/op | |
middle (neg index) 10000000 0.58 µs/op | |
out of bound (neg index) 10000000 0.73 µs/op | |
out of bound 10000000 0.90 µs/op | |
last (neg index) 5000000 1.07 µs/op | |
## :"struct_single (1 elem), slice_count: 100" | |
benchmark name iterations average time | |
middle 10000000 0.42 µs/op | |
last 10000000 0.42 µs/op | |
middle (neg index) 10000000 0.42 µs/op | |
first 10000000 0.42 µs/op | |
first (neg index) 10000000 0.43 µs/op | |
out of bound 10000000 0.78 µs/op | |
out of bound (neg index) 10000000 0.79 µs/op | |
last (neg index) 10000000 0.86 µs/op | |
## :"range_huge (500000 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 10000000 0.42 µs/op | |
middle 200 23409.19 µs/op | |
last 100 47861.35 µs/op | |
out of bound (neg index) 100 83490.58 µs/op | |
out of bound 100 84739.91 µs/op | |
first (neg index) 100 87191.30 µs/op | |
middle (neg index) 100 88484.08 µs/op | |
last (neg index) 50 90478.84 µs/op | |
## :"map_big (100000 elem), slice_count: 100" | |
benchmark name iterations average time | |
first 1000 3072.67 µs/op | |
middle 1000 7371.24 µs/op | |
last 500 13055.17 µs/op | |
out of bound 500 20253.86 µs/op | |
out of bound (neg index) 500 20925.56 µs/op | |
middle (neg index) 200 20962.87 µs/op | |
last (neg index) 200 21834.27 µs/op | |
first (neg index) 500 22027.22 µs/op | |
## :"map (1000 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 200000 26.73 µs/op | |
middle 100000 68.89 µs/op | |
last 50000 123.27 µs/op | |
out of bound 50000 199.36 µs/op | |
first (neg index) 50000 205.56 µs/op | |
middle (neg index) 50000 209.60 µs/op | |
last (neg index) 50000 209.74 µs/op | |
out of bound (neg index) 50000 233.11 µs/op | |
## :"struct_big (100000 elem), slice_count: 990" | |
benchmark name iterations average time | |
first 2000 2794.11 µs/op | |
middle 1000 6748.21 µs/op | |
last 500 12026.15 µs/op | |
out of bound (neg index) 500 18162.18 µs/op | |
out of bound 500 18174.33 µs/op | |
middle (neg index) 500 18929.24 µs/op | |
last (neg index) 500 20038.18 µs/op | |
first (neg index) 500 22018.76 µs/op | |
## :"list_big (100000 elem), slice_count: 100" | |
benchmark name iterations average time | |
first 5000000 2.28 µs/op | |
out of bound 50000 142.77 µs/op | |
out of bound (neg index) 50000 142.83 µs/op | |
first (neg index) 50000 146.29 µs/op | |
middle 10000 678.47 µs/op | |
middle (neg index) 10000 826.55 µs/op | |
last 5000 1373.08 µs/op | |
last (neg index) 5000 1535.76 µs/op | |
## :"range_single (1 elem), slice_count: 1" | |
benchmark name iterations average time | |
first (neg index) 10000000 0.41 µs/op | |
middle (neg index) 10000000 0.41 µs/op | |
first 10000000 0.41 µs/op | |
last 10000000 0.41 µs/op | |
middle 10000000 0.42 µs/op | |
out of bound 10000000 0.68 µs/op | |
out of bound (neg index) 10000000 0.72 µs/op | |
last (neg index) 10000000 0.82 µs/op | |
## :"struct_empty (0 elem), slice_count: 990" | |
benchmark name iterations average time | |
first (neg index) 10000000 0.33 µs/op | |
first 100000000 0.34 µs/op | |
middle 100000000 0.34 µs/op | |
middle (neg index) 10000000 0.40 µs/op | |
last 10000000 0.54 µs/op | |
out of bound (neg index) 10000000 0.55 µs/op | |
out of bound 10000000 0.58 µs/op | |
last (neg index) 10000000 0.74 µs/op | |
## :"list_empty (0 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 100000000 0.06 µs/op | |
middle 100000000 0.06 µs/op | |
middle (neg index) 100000000 0.06 µs/op | |
first (neg index) 100000000 0.07 µs/op | |
out of bound (neg index) 100000000 0.12 µs/op | |
out of bound 100000000 0.12 µs/op | |
last (neg index) 100000000 0.14 µs/op | |
last 100000000 0.14 µs/op | |
## :"struct_huge (500000 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 500 12199.43 µs/op | |
middle 100 34855.81 µs/op | |
last 100 55246.65 µs/op | |
last (neg index) 50 90692.76 µs/op | |
out of bound 50 90806.24 µs/op | |
middle (neg index) 50 91109.96 µs/op | |
first (neg index) 50 92790.34 µs/op | |
out of bound (neg index) 50 93017.66 µs/op | |
## :"struct_single (1 elem), slice_count: 1" | |
benchmark name iterations average time | |
last 10000000 0.40 µs/op | |
first (neg index) 10000000 0.40 µs/op | |
first 10000000 0.40 µs/op | |
middle (neg index) 10000000 0.41 µs/op | |
middle 10000000 0.41 µs/op | |
out of bound (neg index) 10000000 0.79 µs/op | |
out of bound 10000000 0.80 µs/op | |
last (neg index) 10000000 0.86 µs/op | |
## :"struct_empty (0 elem), slice_count: 0" | |
benchmark name iterations average time | |
middle (neg index) 100000000 0.28 µs/op | |
first 100000000 0.28 µs/op | |
middle 100000000 0.29 µs/op | |
first (neg index) 100000000 0.29 µs/op | |
out of bound (neg index) 10000000 0.47 µs/op | |
out of bound 10000000 0.48 µs/op | |
last 10000000 0.48 µs/op | |
last (neg index) 10000000 0.48 µs/op | |
## :"struct_huge (500000 elem), slice_count: 990" | |
benchmark name iterations average time | |
first 500 12738.58 µs/op | |
middle 100 35616.32 µs/op | |
last 100 58201.40 µs/op | |
first (neg index) 50 94456.82 µs/op | |
out of bound 50 95145.48 µs/op | |
middle (neg index) 50 99924.54 µs/op | |
out of bound (neg index) 50 130406.62 µs/op | |
last (neg index) 50 139654.94 µs/op | |
## :"range_big (100000 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 10000000 0.43 µs/op | |
middle 1000 5072.98 µs/op | |
last 500 12552.66 µs/op | |
out of bound 500 15159.93 µs/op | |
out of bound (neg index) 500 15164.39 µs/op | |
first (neg index) 500 16138.69 µs/op | |
middle (neg index) 500 16536.93 µs/op | |
last (neg index) 500 17354.42 µs/op | |
## :"map (1000 elem), slice_count: 100" | |
benchmark name iterations average time | |
first 100000 37.51 µs/op | |
middle 100000 79.79 µs/op | |
last 50000 119.90 µs/op | |
out of bound 50000 189.89 µs/op | |
out of bound (neg index) 50000 190.45 µs/op | |
first (neg index) 50000 191.90 µs/op | |
middle (neg index) 50000 200.14 µs/op | |
last (neg index) 50000 207.71 µs/op | |
## :"range (1000 elem), slice_count: 990" | |
benchmark name iterations average time | |
middle 50000 93.40 µs/op | |
last 50000 99.57 µs/op | |
first 50000 110.40 µs/op | |
out of bound 50000 150.03 µs/op | |
out of bound (neg index) 50000 154.35 µs/op | |
last (neg index) 50000 166.26 µs/op | |
middle (neg index) 50000 181.59 µs/op | |
first (neg index) 50000 190.78 µs/op | |
## :"list_single (1 elem), slice_count: 0" | |
benchmark name iterations average time | |
middle 100000000 0.06 µs/op | |
middle (neg index) 100000000 0.06 µs/op | |
first 100000000 0.06 µs/op | |
last 100000000 0.06 µs/op | |
first (neg index) 100000000 0.06 µs/op | |
out of bound (neg index) 100000000 0.12 µs/op | |
out of bound 100000000 0.12 µs/op | |
last (neg index) 100000000 0.13 µs/op | |
## :"list_empty (0 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 100000000 0.07 µs/op | |
middle 100000000 0.07 µs/op | |
middle (neg index) 100000000 0.07 µs/op | |
first (neg index) 100000000 0.09 µs/op | |
last 100000000 0.12 µs/op | |
out of bound 100000000 0.13 µs/op | |
last (neg index) 100000000 0.14 µs/op | |
out of bound (neg index) 100000000 0.15 µs/op | |
## :"map_big (100000 elem), slice_count: 990" | |
benchmark name iterations average time | |
first 1000 4154.21 µs/op | |
middle 1000 7670.21 µs/op | |
last 500 12410.09 µs/op | |
first (neg index) 200 20705.54 µs/op | |
out of bound (neg index) 500 21128.17 µs/op | |
middle (neg index) 500 25599.15 µs/op | |
out of bound 200 28098.85 µs/op | |
last (neg index) 200 31368.46 µs/op | |
## :"list (1000 elem), slice_count: 100" | |
benchmark name iterations average time | |
out of bound 5000000 1.53 µs/op | |
out of bound (neg index) 5000000 1.55 µs/op | |
first 5000000 2.33 µs/op | |
first (neg index) 1000000 3.89 µs/op | |
middle 500000 9.30 µs/op | |
middle (neg index) 500000 10.61 µs/op | |
last 500000 13.74 µs/op | |
last (neg index) 500000 15.36 µs/op | |
## :"struct_single (1 elem), slice_count: 0" | |
benchmark name iterations average time | |
first (neg index) 10000000 0.40 µs/op | |
middle (neg index) 10000000 0.40 µs/op | |
first 10000000 0.41 µs/op | |
last 10000000 0.41 µs/op | |
middle 10000000 0.41 µs/op | |
out of bound (neg index) 10000000 0.79 µs/op | |
out of bound 10000000 0.79 µs/op | |
last (neg index) 10000000 0.82 µs/op | |
## :"map_single (1 elem), slice_count: 990" | |
benchmark name iterations average time | |
first 10000000 0.41 µs/op | |
first (neg index) 10000000 0.42 µs/op | |
last 10000000 0.43 µs/op | |
middle 10000000 0.47 µs/op | |
middle (neg index) 10000000 0.58 µs/op | |
out of bound (neg index) 10000000 0.63 µs/op | |
out of bound 10000000 0.63 µs/op | |
last (neg index) 10000000 0.84 µs/op | |
## :"range (1000 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 10000000 0.42 µs/op | |
middle 100000 50.57 µs/op | |
last 50000 96.40 µs/op | |
last (neg index) 50000 151.18 µs/op | |
out of bound (neg index) 50000 151.30 µs/op | |
middle (neg index) 50000 151.91 µs/op | |
first (neg index) 50000 152.73 µs/op | |
out of bound 50000 159.73 µs/op | |
## :"map_single (1 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 10000000 0.37 µs/op | |
middle (neg index) 10000000 0.38 µs/op | |
middle 10000000 0.38 µs/op | |
last 10000000 0.38 µs/op | |
first (neg index) 10000000 0.39 µs/op | |
out of bound 10000000 0.58 µs/op | |
out of bound (neg index) 10000000 0.59 µs/op | |
last (neg index) 10000000 0.67 µs/op | |
## :"struct_big (100000 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 2000 2492.39 µs/op | |
middle 1000 7381.00 µs/op | |
last 500 11583.08 µs/op | |
out of bound 500 18124.77 µs/op | |
last (neg index) 500 18139.94 µs/op | |
first (neg index) 500 18247.22 µs/op | |
middle (neg index) 500 18297.07 µs/op | |
out of bound (neg index) 500 18478.09 µs/op | |
## :"range_huge (500000 elem), slice_count: 100" | |
benchmark name iterations average time | |
first 500000 10.14 µs/op | |
middle 200 23117.58 µs/op | |
last 100 48160.91 µs/op | |
first (neg index) 100 84060.61 µs/op | |
out of bound (neg index) 100 84503.47 µs/op | |
out of bound 100 84568.53 µs/op | |
middle (neg index) 100 87350.08 µs/op | |
last (neg index) 50 92734.62 µs/op | |
## :"range_big (100000 elem), slice_count: 990" | |
benchmark name iterations average time | |
first 50000 109.46 µs/op | |
middle 1000 6393.48 µs/op | |
last 500 11959.57 µs/op | |
first (neg index) 500 15194.38 µs/op | |
out of bound (neg index) 500 15196.21 µs/op | |
out of bound 500 15946.63 µs/op | |
last (neg index) 200 16387.44 µs/op | |
middle (neg index) 500 19179.67 µs/op | |
## :"map_empty (0 elem), slice_count: 100" | |
benchmark name iterations average time | |
middle (neg index) 100000000 0.26 µs/op | |
middle 100000000 0.29 µs/op | |
first (neg index) 100000000 0.30 µs/op | |
first 100000000 0.30 µs/op | |
out of bound (neg index) 10000000 0.38 µs/op | |
out of bound 10000000 0.39 µs/op | |
last (neg index) 10000000 0.40 µs/op | |
last 10000000 0.58 µs/op | |
## :"struct_big (100000 elem), slice_count: 100" | |
benchmark name iterations average time | |
first 2000 2502.25 µs/op | |
middle 1000 7210.82 µs/op | |
last 500 11514.52 µs/op | |
out of bound 500 18166.20 µs/op | |
first (neg index) 500 18315.18 µs/op | |
out of bound (neg index) 500 19024.21 µs/op | |
middle (neg index) 500 19323.57 µs/op | |
last (neg index) 500 19797.18 µs/op | |
## :"struct_single (1 elem), slice_count: 990" | |
benchmark name iterations average time | |
first 10000000 0.42 µs/op | |
first (neg index) 10000000 0.42 µs/op | |
middle (neg index) 10000000 0.42 µs/op | |
middle 10000000 0.43 µs/op | |
last 10000000 0.44 µs/op | |
out of bound 10000000 0.79 µs/op | |
out of bound (neg index) 10000000 0.79 µs/op | |
last (neg index) 10000000 0.87 µs/op | |
## :"list_empty (0 elem), slice_count: 100" | |
benchmark name iterations average time | |
middle 100000000 0.07 µs/op | |
middle (neg index) 100000000 0.07 µs/op | |
first 100000000 0.07 µs/op | |
first (neg index) 100000000 0.09 µs/op | |
out of bound (neg index) 100000000 0.12 µs/op | |
last (neg index) 100000000 0.12 µs/op | |
out of bound 100000000 0.13 µs/op | |
last 100000000 0.14 µs/op | |
## :"list_huge (500000 elem), slice_count: 100" | |
benchmark name iterations average time | |
first 5000000 2.30 µs/op | |
out of bound (neg index) 10000 800.95 µs/op | |
out of bound 10000 801.89 µs/op | |
first (neg index) 10000 801.97 µs/op | |
middle 1000 3454.39 µs/op | |
middle (neg index) 1000 4247.92 µs/op | |
last 1000 7074.42 µs/op | |
last (neg index) 1000 8030.90 µs/op | |
## :"map_huge (500000 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 500 16259.35 µs/op | |
middle 100 40117.90 µs/op | |
last 100 62872.85 µs/op | |
out of bound (neg index) 50 106719.40 µs/op | |
out of bound 50 108785.12 µs/op | |
first (neg index) 50 110314.72 µs/op | |
last (neg index) 50 112792.06 µs/op | |
middle (neg index) 50 139817.56 µs/op | |
## :"list_single (1 elem), slice_count: 1" | |
benchmark name iterations average time | |
middle (neg index) 100000000 0.09 µs/op | |
last 100000000 0.09 µs/op | |
first 100000000 0.09 µs/op | |
first (neg index) 100000000 0.09 µs/op | |
middle 100000000 0.09 µs/op | |
out of bound 100000000 0.12 µs/op | |
out of bound (neg index) 100000000 0.12 µs/op | |
last (neg index) 100000000 0.17 µs/op | |
## :"struct_big (100000 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 2000 2468.84 µs/op | |
middle 1000 7211.19 µs/op | |
last 500 12018.47 µs/op | |
out of bound 500 18139.90 µs/op | |
middle (neg index) 500 18891.76 µs/op | |
last (neg index) 500 19962.33 µs/op | |
out of bound (neg index) 500 22465.27 µs/op | |
first (neg index) 500 22517.13 µs/op | |
## :"list_huge (500000 elem), slice_count: 990" | |
benchmark name iterations average time | |
first 200000 22.39 µs/op | |
out of bound (neg index) 10000 794.23 µs/op | |
out of bound 10000 794.80 µs/op | |
first (neg index) 10000 830.05 µs/op | |
middle 1000 3698.45 µs/op | |
middle (neg index) 1000 4531.25 µs/op | |
last 1000 7064.30 µs/op | |
last (neg index) 1000 8080.21 µs/op | |
## :"list_empty (0 elem), slice_count: 990" | |
benchmark name iterations average time | |
first 100000000 0.06 µs/op | |
middle (neg index) 100000000 0.06 µs/op | |
middle 100000000 0.06 µs/op | |
first (neg index) 100000000 0.08 µs/op | |
last (neg index) 100000000 0.12 µs/op | |
out of bound 100000000 0.12 µs/op | |
out of bound (neg index) 100000000 0.12 µs/op | |
last 100000000 0.12 µs/op | |
## :"range_huge (500000 elem), slice_count: 990" | |
benchmark name iterations average time | |
first 50000 115.87 µs/op | |
middle 200 23254.31 µs/op | |
last 100 62331.05 µs/op | |
out of bound (neg index) 50 85970.74 µs/op | |
first (neg index) 50 87445.96 µs/op | |
out of bound 50 87550.42 µs/op | |
last (neg index) 50 93016.84 µs/op | |
middle (neg index) 50 127239.02 µs/op | |
## :"struct (1000 elem), slice_count: 990" | |
benchmark name iterations average time | |
last 50000 101.83 µs/op | |
middle 50000 110.83 µs/op | |
first 50000 119.91 µs/op | |
out of bound 50000 166.83 µs/op | |
out of bound (neg index) 50000 167.88 µs/op | |
last (neg index) 50000 181.52 µs/op | |
middle (neg index) 50000 189.69 µs/op | |
first (neg index) 50000 197.67 µs/op | |
## :"map_empty (0 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 100000000 0.25 µs/op | |
middle (neg index) 100000000 0.25 µs/op | |
middle 100000000 0.26 µs/op | |
first (neg index) 100000000 0.27 µs/op | |
out of bound (neg index) 10000000 0.38 µs/op | |
last (neg index) 10000000 0.38 µs/op | |
out of bound 10000000 0.39 µs/op | |
last 10000000 0.39 µs/op | |
## :"list (1000 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 100000000 0.11 µs/op | |
out of bound (neg index) 5000000 1.53 µs/op | |
out of bound 5000000 1.54 µs/op | |
first (neg index) 5000000 1.65 µs/op | |
middle (neg index) 500000 8.38 µs/op | |
middle 1000000 8.95 µs/op | |
last 500000 14.53 µs/op | |
last (neg index) 500000 16.02 µs/op | |
## :"list (1000 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 100000000 0.06 µs/op | |
last 100000000 0.07 µs/op | |
middle 100000000 0.07 µs/op | |
out of bound (neg index) 5000000 1.52 µs/op | |
first (neg index) 5000000 1.55 µs/op | |
middle (neg index) 5000000 1.57 µs/op | |
out of bound 5000000 1.58 µs/op | |
last (neg index) 5000000 1.59 µs/op | |
## :"map_single (1 elem), slice_count: 100" | |
benchmark name iterations average time | |
first 10000000 0.40 µs/op | |
middle 10000000 0.40 µs/op | |
first (neg index) 10000000 0.41 µs/op | |
middle (neg index) 10000000 0.41 µs/op | |
last 10000000 0.42 µs/op | |
out of bound 10000000 0.60 µs/op | |
out of bound (neg index) 10000000 0.60 µs/op | |
last (neg index) 10000000 0.67 µs/op | |
## :"map_huge (500000 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 500 15582.06 µs/op | |
middle 100 38192.82 µs/op | |
last 100 60533.26 µs/op | |
out of bound 50 101632.00 µs/op | |
middle (neg index) 50 102194.04 µs/op | |
out of bound (neg index) 50 102278.32 µs/op | |
first (neg index) 50 103838.12 µs/op | |
last (neg index) 50 103887.72 µs/op | |
## :"list_huge (500000 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 100000000 0.06 µs/op | |
middle 100000000 0.07 µs/op | |
last 100000000 0.07 µs/op | |
middle (neg index) 10000 795.22 µs/op | |
out of bound 10000 799.67 µs/op | |
out of bound (neg index) 10000 803.39 µs/op | |
first (neg index) 10000 818.22 µs/op | |
last (neg index) 10000 824.09 µs/op | |
## :"range_single (1 elem), slice_count: 100" | |
benchmark name iterations average time | |
first 10000000 0.45 µs/op | |
last 10000000 0.45 µs/op | |
middle (neg index) 10000000 0.47 µs/op | |
middle 10000000 0.63 µs/op | |
first (neg index) 10000000 0.63 µs/op | |
out of bound 10000000 0.71 µs/op | |
last (neg index) 10000000 0.85 µs/op | |
out of bound (neg index) 10000000 0.86 µs/op | |
## :"list_huge (500000 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 100000000 0.09 µs/op | |
out of bound 10000 799.49 µs/op | |
first (neg index) 10000 801.70 µs/op | |
out of bound (neg index) 10000 812.75 µs/op | |
middle 1000 3497.47 µs/op | |
middle (neg index) 1000 4316.97 µs/op | |
last 1000 6934.65 µs/op | |
last (neg index) 1000 7883.91 µs/op | |
## :"map_empty (0 elem), slice_count: 990" | |
benchmark name iterations average time | |
middle 100000000 0.26 µs/op | |
middle (neg index) 100000000 0.26 µs/op | |
first 100000000 0.26 µs/op | |
first (neg index) 100000000 0.27 µs/op | |
last (neg index) 10000000 0.38 µs/op | |
last 10000000 0.39 µs/op | |
out of bound (neg index) 10000000 0.39 µs/op | |
out of bound 10000000 0.39 µs/op | |
## :"range_big (100000 elem), slice_count: 100" | |
benchmark name iterations average time | |
first 500000 10.27 µs/op | |
middle 1000 4898.60 µs/op | |
last 500 9869.52 µs/op | |
out of bound (neg index) 500 15293.40 µs/op | |
out of bound 500 15382.54 µs/op | |
first (neg index) 500 15942.63 µs/op | |
middle (neg index) 500 17191.62 µs/op | |
last (neg index) 500 20579.58 µs/op | |
## :"list_big (100000 elem), slice_count: 990" | |
benchmark name iterations average time | |
first 500000 23.69 µs/op | |
out of bound 50000 142.59 µs/op | |
out of bound (neg index) 50000 145.60 µs/op | |
first (neg index) 50000 167.62 µs/op | |
middle 10000 721.34 µs/op | |
middle (neg index) 10000 866.67 µs/op | |
last 5000 1422.30 µs/op | |
last (neg index) 5000 1578.98 µs/op | |
## :"range (1000 elem), slice_count: 100" | |
benchmark name iterations average time | |
first 500000 9.90 µs/op | |
middle 100000 57.71 µs/op | |
last 50000 102.23 µs/op | |
out of bound (neg index) 50000 148.09 µs/op | |
out of bound 50000 149.29 µs/op | |
first (neg index) 50000 157.93 µs/op | |
middle (neg index) 50000 158.03 µs/op | |
last (neg index) 50000 166.00 µs/op | |
## :"list_big (100000 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 100000000 0.06 µs/op | |
last 100000000 0.07 µs/op | |
middle 100000000 0.07 µs/op | |
last (neg index) 50000 142.73 µs/op | |
out of bound (neg index) 50000 142.94 µs/op | |
out of bound 50000 145.16 µs/op | |
first (neg index) 50000 146.18 µs/op | |
middle (neg index) 50000 146.34 µs/op | |
## :"struct_empty (0 elem), slice_count: 100" | |
benchmark name iterations average time | |
first 100000000 0.29 µs/op | |
middle 100000000 0.29 µs/op | |
first (neg index) 100000000 0.30 µs/op | |
middle (neg index) 100000000 0.34 µs/op | |
last (neg index) 10000000 0.54 µs/op | |
last 10000000 0.54 µs/op | |
out of bound (neg index) 10000000 0.56 µs/op | |
out of bound 10000000 0.76 µs/op | |
## :"list (1000 elem), slice_count: 990" | |
benchmark name iterations average time | |
out of bound 5000000 1.53 µs/op | |
out of bound (neg index) 5000000 1.54 µs/op | |
last 500000 14.60 µs/op | |
last (neg index) 500000 16.34 µs/op | |
middle 500000 19.58 µs/op | |
middle (neg index) 500000 21.38 µs/op | |
first (neg index) 200000 26.37 µs/op | |
first 200000 32.75 µs/op | |
## :"map (1000 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 200000 25.29 µs/op | |
middle 100000 66.88 µs/op | |
last 50000 121.09 µs/op | |
last (neg index) 50000 191.40 µs/op | |
out of bound 50000 192.07 µs/op | |
first (neg index) 50000 192.62 µs/op | |
middle (neg index) 50000 193.65 µs/op | |
out of bound (neg index) 50000 195.86 µs/op | |
## :"struct_huge (500000 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 500 12239.28 µs/op | |
middle 100 35538.12 µs/op | |
last 100 56538.23 µs/op | |
out of bound 50 91267.82 µs/op | |
out of bound (neg index) 50 91489.06 µs/op | |
first (neg index) 50 91780.16 µs/op | |
middle (neg index) 50 94422.48 µs/op | |
last (neg index) 50 98330.30 µs/op | |
## :"map_empty (0 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 100000000 0.26 µs/op | |
middle (neg index) 100000000 0.26 µs/op | |
middle 100000000 0.26 µs/op | |
first (neg index) 100000000 0.27 µs/op | |
out of bound (neg index) 10000000 0.38 µs/op | |
last 10000000 0.39 µs/op | |
out of bound 10000000 0.39 µs/op | |
last (neg index) 10000000 0.39 µs/op | |
## :"list_single (1 elem), slice_count: 990" | |
benchmark name iterations average time | |
first 100000000 0.09 µs/op | |
middle 100000000 0.09 µs/op | |
first (neg index) 100000000 0.09 µs/op | |
middle (neg index) 100000000 0.09 µs/op | |
last 100000000 0.09 µs/op | |
out of bound 100000000 0.12 µs/op | |
out of bound (neg index) 100000000 0.12 µs/op | |
last (neg index) 100000000 0.17 µs/op | |
## :"map_huge (500000 elem), slice_count: 990" | |
benchmark name iterations average time | |
first 500 16085.87 µs/op | |
middle 100 37264.00 µs/op | |
last 100 59955.25 µs/op | |
first (neg index) 50 103838.84 µs/op | |
out of bound 50 105633.44 µs/op | |
middle (neg index) 50 106615.34 µs/op | |
last (neg index) 50 108954.40 µs/op | |
out of bound (neg index) 50 111288.88 µs/op | |
## :"range_huge (500000 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 10000000 0.43 µs/op | |
middle 200 25182.85 µs/op | |
last 100 47202.20 µs/op | |
first (neg index) 100 83568.62 µs/op | |
out of bound (neg index) 100 84134.16 µs/op | |
middle (neg index) 100 84138.20 µs/op | |
out of bound 100 84374.94 µs/op | |
last (neg index) 50 88311.22 µs/op | |
## :"map (1000 elem), slice_count: 990" | |
benchmark name iterations average time | |
middle 50000 115.49 µs/op | |
last 50000 119.99 µs/op | |
first 50000 123.36 µs/op | |
out of bound 50000 191.49 µs/op | |
out of bound (neg index) 50000 192.73 µs/op | |
last (neg index) 50000 205.54 µs/op | |
middle (neg index) 50000 213.63 µs/op | |
first (neg index) 50000 216.68 µs/op | |
## :"list_single (1 elem), slice_count: 100" | |
benchmark name iterations average time | |
first 100000000 0.09 µs/op | |
last 100000000 0.09 µs/op | |
middle (neg index) 100000000 0.09 µs/op | |
middle 100000000 0.09 µs/op | |
first (neg index) 100000000 0.09 µs/op | |
out of bound (neg index) 100000000 0.12 µs/op | |
out of bound 100000000 0.12 µs/op | |
last (neg index) 100000000 0.17 µs/op | |
EnumSlice.Rewritten.slice/3 - Elixir v1.4.0-dev (8b99214) | |
Settings: | |
duration: 3.0 s | |
Finished in 6951.31 seconds | |
## :"range_single (1 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 100000000 0.05 µs/op | |
first (neg index) 100000000 0.05 µs/op | |
out of bound 100000000 0.05 µs/op | |
out of bound (neg index) 100000000 0.06 µs/op | |
last 100000000 0.06 µs/op | |
last (neg index) 100000000 0.06 µs/op | |
middle 100000000 0.06 µs/op | |
middle (neg index) 100000000 0.06 µs/op | |
## :"struct_huge (500000 elem), slice_count: 100" | |
benchmark name iterations average time | |
out of bound (neg index) 100000000 0.27 µs/op | |
out of bound 100000000 0.27 µs/op | |
first (neg index) 500 12224.64 µs/op | |
first 500 12643.27 µs/op | |
middle (neg index) 100 35213.95 µs/op | |
middle 100 36424.96 µs/op | |
last (neg index) 100 56994.57 µs/op | |
last 100 59164.27 µs/op | |
## :"range (1000 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 100000000 0.17 µs/op | |
last 100000000 0.17 µs/op | |
middle 100000000 0.18 µs/op | |
out of bound 100000000 0.28 µs/op | |
out of bound (neg index) 100000000 0.28 µs/op | |
first (neg index) 10000000 0.49 µs/op | |
middle (neg index) 10000000 0.49 µs/op | |
last (neg index) 10000000 0.49 µs/op | |
## :"list_big (100000 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 100000000 0.13 µs/op | |
out of bound (neg index) 50000 143.35 µs/op | |
out of bound 50000 143.57 µs/op | |
first (neg index) 50000 143.67 µs/op | |
middle 10000 541.14 µs/op | |
middle (neg index) 10000 668.65 µs/op | |
last 5000 1053.39 µs/op | |
last (neg index) 5000 1230.31 µs/op | |
## :"range_big (100000 elem), slice_count: 0" | |
benchmark name iterations average time | |
last (neg index) 100000000 0.05 µs/op | |
last 100000000 0.05 µs/op | |
out of bound (neg index) 100000000 0.05 µs/op | |
out of bound 100000000 0.05 µs/op | |
first (neg index) 100000000 0.05 µs/op | |
first 100000000 0.05 µs/op | |
middle (neg index) 100000000 0.06 µs/op | |
middle 100000000 0.06 µs/op | |
## :"struct_empty (0 elem), slice_count: 1" | |
benchmark name iterations average time | |
first (neg index) 10000000 0.30 µs/op | |
last 10000000 0.31 µs/op | |
first 100000000 0.31 µs/op | |
last (neg index) 100000000 0.31 µs/op | |
out of bound 100000000 0.31 µs/op | |
middle 10000000 0.32 µs/op | |
out of bound (neg index) 10000000 0.33 µs/op | |
middle (neg index) 10000000 0.36 µs/op | |
## :"struct (1000 elem), slice_count: 0" | |
benchmark name iterations average time | |
middle 100000000 0.05 µs/op | |
out of bound 100000000 0.05 µs/op | |
last (neg index) 100000000 0.05 µs/op | |
middle (neg index) 100000000 0.05 µs/op | |
last 100000000 0.05 µs/op | |
first 100000000 0.05 µs/op | |
out of bound (neg index) 100000000 0.05 µs/op | |
first (neg index) 100000000 0.05 µs/op | |
## :"map_big (100000 elem), slice_count: 1" | |
benchmark name iterations average time | |
out of bound (neg index) 10000000 0.31 µs/op | |
out of bound 10000000 0.33 µs/op | |
first (neg index) 1000 3036.43 µs/op | |
first 1000 3376.20 µs/op | |
middle 1000 6484.25 µs/op | |
middle (neg index) 1000 6487.10 µs/op | |
last 500 9811.96 µs/op | |
last (neg index) 500 9874.20 µs/op | |
## :"map_single (1 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 100000000 0.05 µs/op | |
first (neg index) 100000000 0.05 µs/op | |
middle (neg index) 100000000 0.05 µs/op | |
last 100000000 0.05 µs/op | |
out of bound 100000000 0.05 µs/op | |
last (neg index) 100000000 0.05 µs/op | |
middle 100000000 0.05 µs/op | |
out of bound (neg index) 100000000 0.06 µs/op | |
## :"struct (1000 elem), slice_count: 1" | |
benchmark name iterations average time | |
out of bound (neg index) 100000000 0.27 µs/op | |
out of bound 100000000 0.27 µs/op | |
first 500000 20.68 µs/op | |
first (neg index) 500000 21.21 µs/op | |
middle 100000 51.99 µs/op | |
middle (neg index) 100000 52.32 µs/op | |
last 100000 83.68 µs/op | |
last (neg index) 100000 84.28 µs/op | |
## :"map_big (100000 elem), slice_count: 0" | |
benchmark name iterations average time | |
middle 100000000 0.06 µs/op | |
out of bound (neg index) 100000000 0.06 µs/op | |
last (neg index) 100000000 0.06 µs/op | |
out of bound 100000000 0.06 µs/op | |
first 100000000 0.06 µs/op | |
last 100000000 0.06 µs/op | |
middle (neg index) 100000000 0.06 µs/op | |
first (neg index) 100000000 0.06 µs/op | |
## :"struct (1000 elem), slice_count: 100" | |
benchmark name iterations average time | |
out of bound 100000000 0.32 µs/op | |
out of bound (neg index) 100000000 0.33 µs/op | |
first 100000 31.15 µs/op | |
first (neg index) 100000 31.75 µs/op | |
middle 100000 74.43 µs/op | |
middle (neg index) 100000 76.25 µs/op | |
last 50000 105.09 µs/op | |
last (neg index) 50000 146.87 µs/op | |
## :"map_huge (500000 elem), slice_count: 100" | |
benchmark name iterations average time | |
out of bound 100000000 0.28 µs/op | |
out of bound (neg index) 100000000 0.30 µs/op | |
first 500 16938.22 µs/op | |
first (neg index) 500 18274.82 µs/op | |
middle 100 40306.29 µs/op | |
middle (neg index) 100 42240.56 µs/op | |
last (neg index) 100 64234.48 µs/op | |
last 100 65184.59 µs/op | |
## :"range_single (1 elem), slice_count: 990" | |
benchmark name iterations average time | |
out of bound (neg index) 100000000 0.31 µs/op | |
out of bound 100000000 0.31 µs/op | |
first (neg index) 5000000 1.04 µs/op | |
first 5000000 1.06 µs/op | |
middle (neg index) 5000000 1.06 µs/op | |
last 5000000 1.08 µs/op | |
middle 5000000 1.08 µs/op | |
last (neg index) 5000000 1.69 µs/op | |
## :"struct_single (1 elem), slice_count: 100" | |
benchmark name iterations average time | |
out of bound (neg index) 10000000 0.30 µs/op | |
out of bound 100000000 0.32 µs/op | |
last 10000000 0.57 µs/op | |
first (neg index) 10000000 0.58 µs/op | |
middle 10000000 0.59 µs/op | |
first 10000000 0.60 µs/op | |
middle (neg index) 10000000 0.60 µs/op | |
last (neg index) 5000000 1.11 µs/op | |
## :"range_huge (500000 elem), slice_count: 1" | |
benchmark name iterations average time | |
last 100000000 0.20 µs/op | |
middle 100000000 0.21 µs/op | |
first 100000000 0.22 µs/op | |
out of bound 10000000 0.31 µs/op | |
out of bound (neg index) 10000000 0.47 µs/op | |
first (neg index) 10000000 0.50 µs/op | |
last (neg index) 10000000 0.50 µs/op | |
middle (neg index) 10000000 0.56 µs/op | |
## :"map_big (100000 elem), slice_count: 100" | |
benchmark name iterations average time | |
out of bound (neg index) 100000000 0.24 µs/op | |
out of bound 100000000 0.24 µs/op | |
first 1000 3103.26 µs/op | |
first (neg index) 1000 3231.01 µs/op | |
middle 1000 7065.94 µs/op | |
middle (neg index) 1000 7078.80 µs/op | |
last (neg index) 500 12132.76 µs/op | |
last 500 12151.29 µs/op | |
## :"map (1000 elem), slice_count: 1" | |
benchmark name iterations average time | |
out of bound (neg index) 100000000 0.23 µs/op | |
out of bound 100000000 0.23 µs/op | |
first 200000 25.61 µs/op | |
first (neg index) 200000 26.20 µs/op | |
middle 100000 57.59 µs/op | |
middle (neg index) 100000 58.76 µs/op | |
last (neg index) 100000 86.84 µs/op | |
last 100000 87.34 µs/op | |
## :"struct_big (100000 elem), slice_count: 990" | |
benchmark name iterations average time | |
out of bound 100000000 0.27 µs/op | |
out of bound (neg index) 100000000 0.27 µs/op | |
first 2000 2607.37 µs/op | |
first (neg index) 2000 2641.20 µs/op | |
middle (neg index) 1000 6701.54 µs/op | |
middle 1000 6715.49 µs/op | |
last 500 11355.38 µs/op | |
last (neg index) 500 11363.70 µs/op | |
## :"list_big (100000 elem), slice_count: 100" | |
benchmark name iterations average time | |
first 5000000 2.80 µs/op | |
out of bound (neg index) 50000 143.08 µs/op | |
out of bound 50000 143.47 µs/op | |
first (neg index) 50000 146.20 µs/op | |
middle 10000 722.45 µs/op | |
middle (neg index) 5000 867.69 µs/op | |
last 5000 1444.93 µs/op | |
last (neg index) 5000 1606.63 µs/op | |
## :"range_single (1 elem), slice_count: 1" | |
benchmark name iterations average time | |
middle 100000000 0.16 µs/op | |
middle (neg index) 100000000 0.17 µs/op | |
last 100000000 0.17 µs/op | |
first 100000000 0.19 µs/op | |
first (neg index) 100000000 0.19 µs/op | |
out of bound 100000000 0.32 µs/op | |
out of bound (neg index) 100000000 0.32 µs/op | |
last (neg index) 10000000 0.44 µs/op | |
## :"struct_empty (0 elem), slice_count: 990" | |
benchmark name iterations average time | |
out of bound (neg index) 100000000 0.28 µs/op | |
out of bound 100000000 0.28 µs/op | |
last (neg index) 10000000 0.31 µs/op | |
last 100000000 0.34 µs/op | |
middle 10000000 0.42 µs/op | |
middle (neg index) 10000000 0.43 µs/op | |
first 10000000 0.43 µs/op | |
first (neg index) 10000000 0.46 µs/op | |
## :"list_empty (0 elem), slice_count: 0" | |
benchmark name iterations average time | |
last 100000000 0.05 µs/op | |
out of bound 100000000 0.05 µs/op | |
middle (neg index) 100000000 0.05 µs/op | |
middle 100000000 0.05 µs/op | |
first (neg index) 100000000 0.05 µs/op | |
out of bound (neg index) 100000000 0.05 µs/op | |
first 100000000 0.05 µs/op | |
last (neg index) 100000000 0.05 µs/op | |
## :"struct_huge (500000 elem), slice_count: 0" | |
benchmark name iterations average time | |
middle (neg index) 100000000 0.05 µs/op | |
first (neg index) 100000000 0.05 µs/op | |
out of bound 100000000 0.05 µs/op | |
first 100000000 0.05 µs/op | |
last 100000000 0.06 µs/op | |
middle 100000000 0.06 µs/op | |
out of bound (neg index) 100000000 0.06 µs/op | |
last (neg index) 100000000 0.06 µs/op | |
## :"struct_single (1 elem), slice_count: 1" | |
benchmark name iterations average time | |
out of bound 100000000 0.28 µs/op | |
out of bound (neg index) 10000000 0.31 µs/op | |
last 10000000 0.74 µs/op | |
first 10000000 0.74 µs/op | |
first (neg index) 10000000 0.76 µs/op | |
middle (neg index) 10000000 0.78 µs/op | |
middle 10000000 0.78 µs/op | |
last (neg index) 10000000 1.04 µs/op | |
## :"struct_empty (0 elem), slice_count: 0" | |
benchmark name iterations average time | |
middle 100000000 0.05 µs/op | |
middle (neg index) 100000000 0.05 µs/op | |
last (neg index) 100000000 0.06 µs/op | |
out of bound 100000000 0.06 µs/op | |
last 100000000 0.06 µs/op | |
out of bound (neg index) 100000000 0.06 µs/op | |
first (neg index) 100000000 0.06 µs/op | |
first 100000000 0.07 µs/op | |
## :"struct_huge (500000 elem), slice_count: 990" | |
benchmark name iterations average time | |
out of bound (neg index) 100000000 0.27 µs/op | |
out of bound 100000000 0.27 µs/op | |
first 500 12287.09 µs/op | |
first (neg index) 500 12341.38 µs/op | |
middle 100 34929.12 µs/op | |
middle (neg index) 100 35515.85 µs/op | |
last 100 55278.14 µs/op | |
last (neg index) 100 55403.31 µs/op | |
## :"range_big (100000 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 100000000 0.20 µs/op | |
last 100000000 0.20 µs/op | |
middle 100000000 0.21 µs/op | |
out of bound 10000000 0.31 µs/op | |
out of bound (neg index) 10000000 0.46 µs/op | |
last (neg index) 10000000 0.49 µs/op | |
first (neg index) 10000000 0.50 µs/op | |
middle (neg index) 10000000 0.60 µs/op | |
## :"map (1000 elem), slice_count: 100" | |
benchmark name iterations average time | |
out of bound (neg index) 100000000 0.24 µs/op | |
out of bound 100000000 0.24 µs/op | |
first (neg index) 100000 36.72 µs/op | |
first 100000 38.52 µs/op | |
middle 100000 84.61 µs/op | |
middle (neg index) 100000 84.64 µs/op | |
last (neg index) 50000 119.53 µs/op | |
last 50000 125.80 µs/op | |
## :"range (1000 elem), slice_count: 990" | |
benchmark name iterations average time | |
out of bound 100000000 0.28 µs/op | |
out of bound (neg index) 100000000 0.28 µs/op | |
last 5000000 1.09 µs/op | |
last (neg index) 5000000 1.65 µs/op | |
middle 100000 40.71 µs/op | |
middle (neg index) 100000 42.29 µs/op | |
first 100000 84.89 µs/op | |
first (neg index) 100000 84.97 µs/op | |
## :"list_single (1 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 100000000 0.05 µs/op | |
middle 100000000 0.05 µs/op | |
last 100000000 0.05 µs/op | |
last (neg index) 100000000 0.05 µs/op | |
out of bound 100000000 0.05 µs/op | |
out of bound (neg index) 100000000 0.05 µs/op | |
first (neg index) 100000000 0.05 µs/op | |
middle (neg index) 100000000 0.05 µs/op | |
## :"list_empty (0 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 100000000 0.11 µs/op | |
middle (neg index) 100000000 0.14 µs/op | |
middle 100000000 0.14 µs/op | |
first (neg index) 100000000 0.15 µs/op | |
last 100000000 0.21 µs/op | |
out of bound (neg index) 100000000 0.24 µs/op | |
out of bound 100000000 0.26 µs/op | |
last (neg index) 100000000 0.26 µs/op | |
## :"map_big (100000 elem), slice_count: 990" | |
benchmark name iterations average time | |
out of bound (neg index) 100000000 0.23 µs/op | |
out of bound 100000000 0.23 µs/op | |
first (neg index) 1000 3089.08 µs/op | |
first 1000 3262.23 µs/op | |
middle (neg index) 1000 7203.52 µs/op | |
middle 1000 7245.47 µs/op | |
last 500 11715.82 µs/op | |
last (neg index) 500 11794.79 µs/op | |
## :"list (1000 elem), slice_count: 100" | |
benchmark name iterations average time | |
out of bound 5000000 1.62 µs/op | |
out of bound (neg index) 5000000 1.63 µs/op | |
first 5000000 2.33 µs/op | |
first (neg index) 1000000 4.08 µs/op | |
middle 500000 9.33 µs/op | |
middle (neg index) 500000 10.98 µs/op | |
last 500000 13.71 µs/op | |
last (neg index) 500000 15.36 µs/op | |
## :"struct_single (1 elem), slice_count: 0" | |
benchmark name iterations average time | |
middle 100000000 0.05 µs/op | |
out of bound 100000000 0.05 µs/op | |
out of bound (neg index) 100000000 0.05 µs/op | |
middle (neg index) 100000000 0.05 µs/op | |
first 100000000 0.05 µs/op | |
first (neg index) 100000000 0.05 µs/op | |
last (neg index) 100000000 0.05 µs/op | |
last 100000000 0.05 µs/op | |
## :"map_single (1 elem), slice_count: 990" | |
benchmark name iterations average time | |
out of bound 100000000 0.25 µs/op | |
out of bound (neg index) 100000000 0.28 µs/op | |
last 10000000 0.57 µs/op | |
middle (neg index) 10000000 0.58 µs/op | |
middle 10000000 0.58 µs/op | |
first (neg index) 10000000 0.58 µs/op | |
first 10000000 0.58 µs/op | |
last (neg index) 10000000 0.92 µs/op | |
## :"range (1000 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 100000000 0.05 µs/op | |
first (neg index) 100000000 0.05 µs/op | |
middle (neg index) 100000000 0.05 µs/op | |
middle 100000000 0.05 µs/op | |
out of bound 100000000 0.06 µs/op | |
last 100000000 0.06 µs/op | |
last (neg index) 100000000 0.06 µs/op | |
out of bound (neg index) 100000000 0.06 µs/op | |
## :"map_single (1 elem), slice_count: 1" | |
benchmark name iterations average time | |
out of bound 100000000 0.25 µs/op | |
out of bound (neg index) 100000000 0.26 µs/op | |
middle 10000000 0.67 µs/op | |
middle (neg index) 10000000 0.67 µs/op | |
first 10000000 0.69 µs/op | |
last 10000000 0.69 µs/op | |
first (neg index) 10000000 0.86 µs/op | |
last (neg index) 5000000 1.02 µs/op | |
## :"struct_big (100000 elem), slice_count: 0" | |
benchmark name iterations average time | |
last (neg index) 100000000 0.05 µs/op | |
out of bound (neg index) 100000000 0.05 µs/op | |
last 100000000 0.05 µs/op | |
middle 100000000 0.06 µs/op | |
out of bound 100000000 0.06 µs/op | |
first (neg index) 100000000 0.06 µs/op | |
middle (neg index) 100000000 0.06 µs/op | |
first 100000000 0.06 µs/op | |
## :"range_huge (500000 elem), slice_count: 100" | |
benchmark name iterations average time | |
out of bound 100000000 0.29 µs/op | |
out of bound (neg index) 100000000 0.29 µs/op | |
last 5000000 1.08 µs/op | |
last (neg index) 5000000 1.83 µs/op | |
middle 500000 9.72 µs/op | |
first 500000 9.74 µs/op | |
first (neg index) 500000 10.11 µs/op | |
middle (neg index) 500000 10.21 µs/op | |
## :"range_big (100000 elem), slice_count: 990" | |
benchmark name iterations average time | |
out of bound (neg index) 100000000 0.28 µs/op | |
out of bound 100000000 0.28 µs/op | |
last 5000000 1.10 µs/op | |
last (neg index) 5000000 1.66 µs/op | |
first (neg index) 100000 84.77 µs/op | |
first 100000 85.26 µs/op | |
middle (neg index) 100000 85.62 µs/op | |
middle 100000 85.82 µs/op | |
## :"map_empty (0 elem), slice_count: 100" | |
benchmark name iterations average time | |
out of bound 100000000 0.25 µs/op | |
out of bound (neg index) 100000000 0.26 µs/op | |
last (neg index) 10000000 0.30 µs/op | |
last 10000000 0.36 µs/op | |
first 10000000 0.38 µs/op | |
first (neg index) 10000000 0.41 µs/op | |
middle (neg index) 10000000 0.45 µs/op | |
middle 10000000 0.46 µs/op | |
## :"struct_big (100000 elem), slice_count: 100" | |
benchmark name iterations average time | |
out of bound (neg index) 100000000 0.27 µs/op | |
out of bound 100000000 0.28 µs/op | |
first (neg index) 2000 2465.62 µs/op | |
first 2000 2535.40 µs/op | |
middle 1000 7050.09 µs/op | |
middle (neg index) 1000 7247.11 µs/op | |
last (neg index) 500 11845.22 µs/op | |
last 500 12196.25 µs/op | |
## :"struct_single (1 elem), slice_count: 990" | |
benchmark name iterations average time | |
out of bound (neg index) 100000000 0.30 µs/op | |
out of bound 10000000 0.46 µs/op | |
first 10000000 0.58 µs/op | |
first (neg index) 10000000 0.59 µs/op | |
middle (neg index) 10000000 0.60 µs/op | |
middle 10000000 0.61 µs/op | |
last 10000000 0.74 µs/op | |
last (neg index) 5000000 1.09 µs/op | |
## :"list_empty (0 elem), slice_count: 100" | |
benchmark name iterations average time | |
middle 100000000 0.13 µs/op | |
first 100000000 0.13 µs/op | |
middle (neg index) 100000000 0.14 µs/op | |
first (neg index) 100000000 0.15 µs/op | |
last 100000000 0.26 µs/op | |
out of bound (neg index) 100000000 0.27 µs/op | |
last (neg index) 100000000 0.27 µs/op | |
out of bound 100000000 0.27 µs/op | |
## :"list_huge (500000 elem), slice_count: 100" | |
benchmark name iterations average time | |
first 5000000 2.77 µs/op | |
out of bound (neg index) 10000 796.10 µs/op | |
out of bound 10000 796.18 µs/op | |
first (neg index) 10000 829.04 µs/op | |
middle 1000 3685.57 µs/op | |
middle (neg index) 1000 4305.91 µs/op | |
last 1000 7265.91 µs/op | |
last (neg index) 1000 8117.15 µs/op | |
## :"map_huge (500000 elem), slice_count: 1" | |
benchmark name iterations average time | |
out of bound 100000000 0.25 µs/op | |
out of bound (neg index) 100000000 0.26 µs/op | |
first 500 16911.00 µs/op | |
first (neg index) 500 17421.92 µs/op | |
middle (neg index) 100 33859.17 µs/op | |
middle 100 35366.16 µs/op | |
last 100 47838.09 µs/op | |
last (neg index) 100 48843.39 µs/op | |
## :"list_single (1 elem), slice_count: 1" | |
benchmark name iterations average time | |
last 100000000 0.15 µs/op | |
first 100000000 0.16 µs/op | |
middle (neg index) 100000000 0.16 µs/op | |
middle 100000000 0.16 µs/op | |
first (neg index) 100000000 0.16 µs/op | |
out of bound (neg index) 100000000 0.22 µs/op | |
out of bound 100000000 0.22 µs/op | |
last (neg index) 10000000 0.51 µs/op | |
## :"struct_big (100000 elem), slice_count: 1" | |
benchmark name iterations average time | |
out of bound 100000000 0.28 µs/op | |
out of bound (neg index) 100000000 0.30 µs/op | |
first 2000 2626.53 µs/op | |
first (neg index) 2000 2633.66 µs/op | |
middle 1000 5522.62 µs/op | |
middle (neg index) 1000 5695.36 µs/op | |
last 500 8931.84 µs/op | |
last (neg index) 500 9038.69 µs/op | |
## :"list_huge (500000 elem), slice_count: 990" | |
benchmark name iterations average time | |
first 500000 22.28 µs/op | |
out of bound (neg index) 10000 798.94 µs/op | |
out of bound 10000 808.96 µs/op | |
first (neg index) 10000 828.24 µs/op | |
middle (neg index) 1000 4506.44 µs/op | |
middle 1000 5342.49 µs/op | |
last 1000 6939.01 µs/op | |
last (neg index) 1000 8396.15 µs/op | |
## :"list_empty (0 elem), slice_count: 990" | |
benchmark name iterations average time | |
first 100000000 0.13 µs/op | |
middle 100000000 0.13 µs/op | |
middle (neg index) 100000000 0.13 µs/op | |
first (neg index) 100000000 0.15 µs/op | |
out of bound (neg index) 100000000 0.25 µs/op | |
out of bound 100000000 0.26 µs/op | |
last 100000000 0.27 µs/op | |
last (neg index) 10000000 0.31 µs/op | |
## :"range_huge (500000 elem), slice_count: 990" | |
benchmark name iterations average time | |
out of bound 100000000 0.28 µs/op | |
out of bound (neg index) 100000000 0.28 µs/op | |
last 5000000 1.09 µs/op | |
last (neg index) 5000000 1.66 µs/op | |
first 100000 84.45 µs/op | |
middle (neg index) 100000 85.40 µs/op | |
middle 100000 85.50 µs/op | |
first (neg index) 100000 91.22 µs/op | |
## :"struct (1000 elem), slice_count: 990" | |
benchmark name iterations average time | |
out of bound 100000000 0.27 µs/op | |
out of bound (neg index) 100000000 0.27 µs/op | |
last (neg index) 50000 103.04 µs/op | |
last 50000 105.27 µs/op | |
middle 50000 109.16 µs/op | |
middle (neg index) 50000 109.70 µs/op | |
first 50000 121.52 µs/op | |
first (neg index) 50000 125.32 µs/op | |
## :"map_empty (0 elem), slice_count: 0" | |
benchmark name iterations average time | |
first (neg index) 100000000 0.05 µs/op | |
middle (neg index) 100000000 0.05 µs/op | |
first 100000000 0.05 µs/op | |
out of bound 100000000 0.06 µs/op | |
middle 100000000 0.06 µs/op | |
last 100000000 0.06 µs/op | |
last (neg index) 100000000 0.06 µs/op | |
out of bound (neg index) 100000000 0.06 µs/op | |
## :"list (1000 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 100000000 0.13 µs/op | |
out of bound (neg index) 5000000 1.62 µs/op | |
out of bound 5000000 1.64 µs/op | |
first (neg index) 5000000 1.90 µs/op | |
middle 1000000 5.41 µs/op | |
middle (neg index) 1000000 7.19 µs/op | |
last 500000 10.73 µs/op | |
last (neg index) 500000 12.55 µs/op | |
## :"list (1000 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 100000000 0.05 µs/op | |
last (neg index) 100000000 0.05 µs/op | |
middle (neg index) 100000000 0.05 µs/op | |
middle 100000000 0.06 µs/op | |
out of bound (neg index) 100000000 0.06 µs/op | |
first (neg index) 100000000 0.06 µs/op | |
out of bound 100000000 0.06 µs/op | |
last 100000000 0.06 µs/op | |
## :"map_single (1 elem), slice_count: 100" | |
benchmark name iterations average time | |
out of bound (neg index) 100000000 0.27 µs/op | |
out of bound 100000000 0.28 µs/op | |
last 10000000 0.60 µs/op | |
middle 10000000 0.61 µs/op | |
middle (neg index) 10000000 0.62 µs/op | |
first 10000000 0.62 µs/op | |
first (neg index) 10000000 0.62 µs/op | |
last (neg index) 5000000 0.95 µs/op | |
## :"map_huge (500000 elem), slice_count: 0" | |
benchmark name iterations average time | |
middle (neg index) 100000000 0.05 µs/op | |
middle 100000000 0.05 µs/op | |
first (neg index) 100000000 0.05 µs/op | |
out of bound 100000000 0.06 µs/op | |
last (neg index) 100000000 0.06 µs/op | |
last 100000000 0.06 µs/op | |
first 100000000 0.06 µs/op | |
out of bound (neg index) 100000000 0.06 µs/op | |
## :"list_huge (500000 elem), slice_count: 0" | |
benchmark name iterations average time | |
first 100000000 0.05 µs/op | |
last (neg index) 100000000 0.05 µs/op | |
out of bound (neg index) 100000000 0.05 µs/op | |
out of bound 100000000 0.06 µs/op | |
middle (neg index) 100000000 0.06 µs/op | |
last 100000000 0.06 µs/op | |
first (neg index) 100000000 0.06 µs/op | |
middle 100000000 0.06 µs/op | |
## :"range_single (1 elem), slice_count: 100" | |
benchmark name iterations average time | |
out of bound 100000000 0.27 µs/op | |
out of bound (neg index) 100000000 0.28 µs/op | |
middle (neg index) 5000000 1.02 µs/op | |
first 5000000 1.03 µs/op | |
first (neg index) 5000000 1.03 µs/op | |
middle 5000000 1.03 µs/op | |
last 5000000 1.04 µs/op | |
last (neg index) 5000000 1.60 µs/op | |
## :"list_huge (500000 elem), slice_count: 1" | |
benchmark name iterations average time | |
first 100000000 0.13 µs/op | |
out of bound (neg index) 10000 796.05 µs/op | |
first (neg index) 10000 797.52 µs/op | |
out of bound 10000 800.29 µs/op | |
middle (neg index) 1000 3832.97 µs/op | |
middle 1000 4086.83 µs/op | |
last 1000 5655.42 µs/op | |
last (neg index) 1000 6414.56 µs/op | |
## :"map_empty (0 elem), slice_count: 990" | |
benchmark name iterations average time | |
out of bound (neg index) 100000000 0.23 µs/op | |
out of bound 100000000 0.23 µs/op | |
last 100000000 0.23 µs/op | |
last (neg index) 100000000 0.23 µs/op | |
middle (neg index) 10000000 0.37 µs/op | |
first 10000000 0.37 µs/op | |
first (neg index) 10000000 0.40 µs/op | |
middle 10000000 0.41 µs/op | |
## :"range_big (100000 elem), slice_count: 100" | |
benchmark name iterations average time | |
out of bound 10000000 0.30 µs/op | |
out of bound (neg index) 100000000 0.32 µs/op | |
last 5000000 1.50 µs/op | |
last (neg index) 5000000 1.74 µs/op | |
first 500000 9.86 µs/op | |
first (neg index) 500000 10.42 µs/op | |
middle 500000 11.12 µs/op | |
middle (neg index) 500000 11.57 µs/op | |
## :"list_big (100000 elem), slice_count: 990" | |
benchmark name iterations average time | |
first 500000 22.19 µs/op | |
out of bound (neg index) 50000 143.57 µs/op | |
out of bound 50000 143.93 µs/op | |
first (neg index) 50000 166.78 µs/op | |
middle (neg index) 10000 895.98 µs/op | |
middle 10000 933.10 µs/op | |
last 5000 1517.89 µs/op | |
last (neg index) 2000 1549.78 µs/op | |
## :"range (1000 elem), slice_count: 100" | |
benchmark name iterations average time | |
out of bound 10000000 0.30 µs/op | |
out of bound (neg index) 100000000 0.33 µs/op | |
last 5000000 1.17 µs/op | |
last (neg index) 5000000 1.73 µs/op | |
first 500000 9.93 µs/op | |
middle 500000 9.96 µs/op | |
middle (neg index) 500000 10.20 µs/op | |
first (neg index) 500000 13.37 µs/op | |
## :"list_big (100000 elem), slice_count: 0" | |
benchmark name iterations average time | |
middle (neg index) 100000000 0.05 µs/op | |
first (neg index) 100000000 0.05 µs/op | |
first 100000000 0.05 µs/op | |
out of bound (neg index) 100000000 0.05 µs/op | |
out of bound 100000000 0.05 µs/op | |
middle 100000000 0.05 µs/op | |
last 100000000 0.05 µs/op | |
last (neg index) 100000000 0.06 µs/op | |
## :"struct_empty (0 elem), slice_count: 100" | |
benchmark name iterations average time | |
last (neg index) 100000000 0.28 µs/op | |
last 100000000 0.28 µs/op | |
out of bound 100000000 0.28 µs/op | |
out of bound (neg index) 100000000 0.28 µs/op | |
first 10000000 0.40 µs/op | |
middle 10000000 0.41 µs/op | |
middle (neg index) 10000000 0.42 µs/op | |
first (neg index) 10000000 0.43 µs/op | |
## :"list (1000 elem), slice_count: 990" | |
benchmark name iterations average time | |
out of bound (neg index) 5000000 1.62 µs/op | |
out of bound 5000000 1.66 µs/op | |
last 500000 14.60 µs/op | |
last (neg index) 500000 16.53 µs/op | |
middle (neg index) 500000 21.25 µs/op | |
middle 500000 22.97 µs/op | |
first 200000 22.97 µs/op | |
first (neg index) 200000 34.12 µs/op | |
## :"map (1000 elem), slice_count: 0" | |
benchmark name iterations average time | |
last 100000000 0.05 µs/op | |
first 100000000 0.05 µs/op | |
first (neg index) 100000000 0.05 µs/op | |
last (neg index) 100000000 0.05 µs/op | |
middle (neg index) 100000000 0.05 µs/op | |
middle 100000000 0.05 µs/op | |
out of bound 100000000 0.05 µs/op | |
out of bound (neg index) 100000000 0.05 µs/op | |
## :"struct_huge (500000 elem), slice_count: 1" | |
benchmark name iterations average time | |
out of bound (neg index) 100000000 0.30 µs/op | |
out of bound 100000000 0.32 µs/op | |
first (neg index) 500 13026.03 µs/op | |
first 500 13089.98 µs/op | |
middle (neg index) 200 29498.33 µs/op | |
middle 100 30389.56 µs/op | |
last (neg index) 100 43344.39 µs/op | |
last 100 45376.45 µs/op | |
## :"map_empty (0 elem), slice_count: 1" | |
benchmark name iterations average time | |
middle (neg index) 100000000 0.22 µs/op | |
middle 100000000 0.22 µs/op | |
last (neg index) 100000000 0.24 µs/op | |
first (neg index) 100000000 0.25 µs/op | |
out of bound (neg index) 100000000 0.25 µs/op | |
out of bound 100000000 0.26 µs/op | |
last 100000000 0.27 µs/op | |
first 10000000 0.30 µs/op | |
## :"list_single (1 elem), slice_count: 990" | |
benchmark name iterations average time | |
middle (neg index) 100000000 0.15 µs/op | |
first 100000000 0.15 µs/op | |
last 100000000 0.17 µs/op | |
middle 100000000 0.17 µs/op | |
first (neg index) 100000000 0.17 µs/op | |
out of bound 100000000 0.22 µs/op | |
out of bound (neg index) 100000000 0.22 µs/op | |
last (neg index) 10000000 0.40 µs/op | |
## :"map_huge (500000 elem), slice_count: 990" | |
benchmark name iterations average time | |
out of bound (neg index) 100000000 0.31 µs/op | |
out of bound 100000000 0.33 µs/op | |
first 500 16849.74 µs/op | |
first (neg index) 500 16984.76 µs/op | |
middle 100 37996.64 µs/op | |
middle (neg index) 100 39059.26 µs/op | |
last (neg index) 100 59712.55 µs/op | |
last 100 60439.92 µs/op | |
## :"range_huge (500000 elem), slice_count: 0" | |
benchmark name iterations average time | |
first (neg index) 100000000 0.05 µs/op | |
last (neg index) 100000000 0.05 µs/op | |
out of bound (neg index) 100000000 0.05 µs/op | |
middle (neg index) 100000000 0.05 µs/op | |
first 100000000 0.05 µs/op | |
last 100000000 0.05 µs/op | |
middle 100000000 0.06 µs/op | |
out of bound 100000000 0.06 µs/op | |
## :"map (1000 elem), slice_count: 990" | |
benchmark name iterations average time | |
out of bound (neg index) 100000000 0.23 µs/op | |
out of bound 100000000 0.23 µs/op | |
middle (neg index) 50000 117.23 µs/op | |
middle 50000 119.25 µs/op | |
first 50000 119.87 µs/op | |
last 50000 120.41 µs/op | |
last (neg index) 50000 120.69 µs/op | |
first (neg index) 50000 120.79 µs/op | |
## :"list_single (1 elem), slice_count: 100" | |
benchmark name iterations average time | |
middle (neg index) 100000000 0.16 µs/op | |
last 100000000 0.17 µs/op | |
first (neg index) 100000000 0.17 µs/op | |
middle 100000000 0.17 µs/op | |
first 100000000 0.17 µs/op | |
out of bound 100000000 0.25 µs/op | |
out of bound (neg index) 100000000 0.25 µs/op | |
last (neg index) 10000000 0.59 µs/op | |
bench/snapshots/2016-07-16_01-47-16.snapshot vs | |
bench/snapshots/2016-07-16_03-43-31.snapshot | |
## :"range_single (1 elem), slice_count: 0" | |
last (neg index) -92.11% | |
out of bound -92.02% | |
out of bound (neg index) -91.98% | |
first -87.02% | |
last -86.94% | |
first (neg index) -86.48% | |
middle -86.25% | |
middle (neg index) -85.61% | |
## :"struct_huge (500000 elem), slice_count: 100" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
first (neg index) -86.60% | |
middle (neg index) -62.99% | |
last (neg index) -41.93% | |
middle +2.27% | |
last +3.83% | |
first +3.97% | |
## :"range (1000 elem), slice_count: 1" | |
last -99.83% | |
out of bound (neg index) -99.82% | |
out of bound -99.82% | |
last (neg index) -99.70% | |
middle (neg index) -99.69% | |
first (neg index) -99.68% | |
middle -99.64% | |
first -59.79% | |
## :"list_big (100000 elem), slice_count: 1" | |
last -22.76% | |
last (neg index) -21.46% | |
middle -21.19% | |
middle (neg index) -19.81% | |
out of bound -0.35% | |
out of bound (neg index) +0.48% | |
first (neg index) +0.57% | |
first +41.42% | |
## :"range_big (100000 elem), slice_count: 0" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
middle (neg index) -100.00% | |
middle -100.00% | |
last (neg index) -100.00% | |
last -100.00% | |
first (neg index) -100.00% | |
first -86.79% | |
## :"struct_empty (0 elem), slice_count: 1" | |
last -42.96% | |
last (neg index) -42.28% | |
out of bound -41.08% | |
out of bound (neg index) -37.64% | |
first (neg index) +2.35% | |
first +6.08% | |
middle +11.45% | |
middle (neg index) +24.19% | |
## :"struct (1000 elem), slice_count: 0" | |
out of bound (neg index) -99.97% | |
out of bound -99.97% | |
middle (neg index) -99.97% | |
last (neg index) -99.97% | |
first (neg index) -99.97% | |
last -99.95% | |
middle -99.92% | |
first -99.74% | |
## :"map_big (100000 elem), slice_count: 1" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
first (neg index) -85.79% | |
middle (neg index) -69.10% | |
last (neg index) -54.84% | |
last -27.55% | |
first -9.33% | |
middle -9.09% | |
## :"map_single (1 elem), slice_count: 0" | |
out of bound -93.35% | |
last (neg index) -91.53% | |
out of bound (neg index) -91.05% | |
first (neg index) -90.22% | |
middle -90.19% | |
first -87.02% | |
last -86.78% | |
middle (neg index) -86.65% | |
## :"struct (1000 elem), slice_count: 1" | |
out of bound (neg index) -99.84% | |
out of bound -99.84% | |
first (neg index) -87.44% | |
middle (neg index) -70.03% | |
last (neg index) -53.52% | |
last -19.23% | |
middle -17.61% | |
first +1.27% | |
## :"map_big (100000 elem), slice_count: 0" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
middle (neg index) -100.00% | |
middle -100.00% | |
last (neg index) -100.00% | |
last -100.00% | |
first (neg index) -100.00% | |
first -100.00% | |
## :"struct (1000 elem), slice_count: 100" | |
out of bound -99.85% | |
out of bound (neg index) -99.83% | |
first (neg index) -85.09% | |
middle (neg index) -58.62% | |
last (neg index) -34.61% | |
first -13.57% | |
last -5.13% | |
middle -0.21% | |
## :"map_huge (500000 elem), slice_count: 100" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
first (neg index) -82.75% | |
middle (neg index) -60.46% | |
last (neg index) -41.99% | |
last +5.57% | |
middle +7.44% | |
first +8.50% | |
## :"range_single (1 elem), slice_count: 990" | |
out of bound -65.62% | |
out of bound (neg index) -57.94% | |
last (neg index) +57.88% | |
middle (neg index) +81.84% | |
first (neg index) +89.34% | |
first +121.49% | |
middle +131.09% | |
last +133.43% | |
## :"struct_single (1 elem), slice_count: 100" | |
out of bound (neg index) -61.77% | |
out of bound -58.95% | |
last (neg index) +28.83% | |
last +35.13% | |
first (neg index) +36.86% | |
first +40.02% | |
middle +40.15% | |
middle (neg index) +43.20% | |
## :"range_huge (500000 elem), slice_count: 1" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
middle (neg index) -100.00% | |
middle -100.00% | |
last (neg index) -100.00% | |
last -100.00% | |
first (neg index) -100.00% | |
first -47.92% | |
## :"map_big (100000 elem), slice_count: 100" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
first (neg index) -85.33% | |
middle (neg index) -66.23% | |
last (neg index) -44.43% | |
last -6.92% | |
middle -4.14% | |
first +1.00% | |
## :"map (1000 elem), slice_count: 1" | |
out of bound (neg index) -99.90% | |
out of bound -99.88% | |
first (neg index) -87.25% | |
middle (neg index) -71.96% | |
last (neg index) -58.60% | |
last -29.15% | |
middle -16.41% | |
first -4.18% | |
## :"struct_big (100000 elem), slice_count: 990" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
first (neg index) -88.00% | |
middle (neg index) -64.60% | |
last (neg index) -43.29% | |
first -6.68% | |
last -5.58% | |
middle -0.48% | |
## :"list_big (100000 elem), slice_count: 100" | |
first (neg index) -0.06% | |
out of bound (neg index) +0.17% | |
out of bound +0.49% | |
last (neg index) +4.61% | |
middle (neg index) +4.98% | |
last +5.23% | |
middle +6.48% | |
first +22.54% | |
## :"range_single (1 elem), slice_count: 1" | |
middle -61.17% | |
middle (neg index) -59.47% | |
last -58.94% | |
out of bound (neg index) -55.33% | |
first -54.09% | |
first (neg index) -53.77% | |
out of bound -52.70% | |
last (neg index) -46.26% | |
## :"struct_empty (0 elem), slice_count: 990" | |
last (neg index) -58.15% | |
out of bound -51.45% | |
out of bound (neg index) -48.67% | |
last -36.79% | |
middle (neg index) +6.17% | |
middle +25.27% | |
first +29.50% | |
first (neg index) +40.61% | |
## :"list_empty (0 elem), slice_count: 0" | |
last -62.02% | |
last (neg index) -59.89% | |
out of bound -56.85% | |
out of bound (neg index) -54.75% | |
first (neg index) -24.48% | |
middle (neg index) -17.03% | |
middle -15.46% | |
first -11.25% | |
## :"struct_huge (500000 elem), slice_count: 0" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
middle (neg index) -100.00% | |
middle -100.00% | |
last (neg index) -100.00% | |
last -100.00% | |
first (neg index) -100.00% | |
first -100.00% | |
## :"struct_single (1 elem), slice_count: 1" | |
out of bound -65.37% | |
out of bound (neg index) -60.53% | |
last (neg index) +20.14% | |
first +84.86% | |
last +85.15% | |
middle (neg index) +90.48% | |
first (neg index) +90.51% | |
middle +91.03% | |
## :"struct_empty (0 elem), slice_count: 0" | |
last (neg index) -88.14% | |
out of bound -88.03% | |
last -88.00% | |
out of bound (neg index) -87.65% | |
middle -81.29% | |
middle (neg index) -80.59% | |
first (neg index) -79.61% | |
first -76.91% | |
## :"struct_huge (500000 elem), slice_count: 990" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
first (neg index) -86.93% | |
middle (neg index) -64.46% | |
last (neg index) -60.33% | |
last -5.02% | |
first -3.54% | |
middle -1.93% | |
## :"range_big (100000 elem), slice_count: 1" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
middle (neg index) -100.00% | |
middle -100.00% | |
last (neg index) -100.00% | |
last -100.00% | |
first (neg index) -100.00% | |
first -53.91% | |
## :"map (1000 elem), slice_count: 100" | |
out of bound (neg index) -99.87% | |
out of bound -99.87% | |
first (neg index) -80.86% | |
middle (neg index) -57.71% | |
last (neg index) -42.45% | |
first +2.69% | |
last +4.92% | |
middle +6.04% | |
## :"range (1000 elem), slice_count: 990" | |
out of bound (neg index) -99.82% | |
out of bound -99.81% | |
last (neg index) -99.01% | |
last -98.91% | |
middle (neg index) -76.71% | |
middle -56.41% | |
first (neg index) -55.46% | |
first -23.11% | |
## :"list_single (1 elem), slice_count: 0" | |
last (neg index) -60.01% | |
out of bound -53.51% | |
out of bound (neg index) -53.41% | |
first -13.59% | |
last -12.13% | |
first (neg index) -11.25% | |
middle -10.98% | |
middle (neg index) -10.23% | |
## :"list_empty (0 elem), slice_count: 1" | |
out of bound (neg index) +66.30% | |
first (neg index) +67.18% | |
first +72.47% | |
last +74.70% | |
last (neg index) +86.33% | |
middle (neg index) +93.00% | |
middle +98.23% | |
out of bound +104.66% | |
## :"map_big (100000 elem), slice_count: 990" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
first (neg index) -85.08% | |
middle (neg index) -71.86% | |
last (neg index) -62.40% | |
first -21.47% | |
last -5.59% | |
middle -5.54% | |
## :"list (1000 elem), slice_count: 100" | |
last -0.26% | |
first -0.16% | |
last (neg index) -0.04% | |
middle +0.34% | |
middle (neg index) +3.51% | |
first (neg index) +4.98% | |
out of bound (neg index) +5.21% | |
out of bound +6.20% | |
## :"struct_single (1 elem), slice_count: 0" | |
last (neg index) -93.57% | |
out of bound -93.39% | |
out of bound (neg index) -93.35% | |
middle -87.42% | |
middle (neg index) -87.06% | |
last -87.04% | |
first -87.03% | |
first (neg index) -86.79% | |
## :"map_single (1 elem), slice_count: 990" | |
out of bound -60.15% | |
out of bound (neg index) -54.75% | |
middle (neg index) -0.40% | |
last (neg index) +10.53% | |
middle +23.97% | |
last +32.53% | |
first (neg index) +37.51% | |
first +43.89% | |
## :"range (1000 elem), slice_count: 0" | |
out of bound -99.97% | |
first (neg index) -99.97% | |
out of bound (neg index) -99.96% | |
middle (neg index) -99.96% | |
last (neg index) -99.96% | |
last -99.94% | |
middle -99.89% | |
first -87.52% | |
## :"map_single (1 elem), slice_count: 1" | |
out of bound (neg index) -56.51% | |
out of bound -56.33% | |
last (neg index) +51.80% | |
middle +76.37% | |
middle (neg index) +79.25% | |
last +80.54% | |
first +83.89% | |
first (neg index) +123.92% | |
## :"struct_big (100000 elem), slice_count: 0" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
middle (neg index) -100.00% | |
middle -100.00% | |
last (neg index) -100.00% | |
last -100.00% | |
first (neg index) -100.00% | |
first -100.00% | |
## :"range_huge (500000 elem), slice_count: 100" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
last (neg index) -100.00% | |
last -100.00% | |
middle (neg index) -99.99% | |
first (neg index) -99.99% | |
middle -99.96% | |
first -3.98% | |
## :"range_big (100000 elem), slice_count: 990" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
last (neg index) -99.99% | |
last -99.99% | |
middle (neg index) -99.55% | |
first (neg index) -99.44% | |
middle -98.66% | |
first -22.11% | |
## :"map_empty (0 elem), slice_count: 100" | |
last -37.59% | |
out of bound -34.05% | |
out of bound (neg index) -31.15% | |
last (neg index) -25.18% | |
first +24.56% | |
first (neg index) +36.40% | |
middle +57.09% | |
middle (neg index) +74.45% | |
## :"struct_big (100000 elem), slice_count: 100" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
first (neg index) -86.54% | |
middle (neg index) -62.50% | |
last (neg index) -40.17% | |
middle -2.23% | |
first +1.32% | |
last +5.92% | |
## :"struct_single (1 elem), slice_count: 990" | |
out of bound (neg index) -61.88% | |
out of bound -41.47% | |
last (neg index) +25.85% | |
first +37.30% | |
first (neg index) +38.67% | |
middle +40.66% | |
middle (neg index) +41.58% | |
last +69.64% | |
## :"list_empty (0 elem), slice_count: 100" | |
first (neg index) +72.50% | |
last +79.88% | |
middle +92.00% | |
first +94.10% | |
out of bound +101.05% | |
middle (neg index) +113.76% | |
last (neg index) +115.24% | |
out of bound (neg index) +119.04% | |
## :"list_huge (500000 elem), slice_count: 100" | |
out of bound -0.71% | |
out of bound (neg index) -0.61% | |
last (neg index) +1.07% | |
middle (neg index) +1.37% | |
last +2.71% | |
first (neg index) +3.38% | |
middle +6.69% | |
first +20.41% | |
## :"map_huge (500000 elem), slice_count: 1" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
first (neg index) -84.21% | |
middle (neg index) -75.78% | |
last (neg index) -56.70% | |
last -23.91% | |
middle -11.84% | |
first +4.01% | |
## :"list_single (1 elem), slice_count: 1" | |
last +63.53% | |
first +72.33% | |
middle +74.54% | |
middle (neg index) +77.14% | |
out of bound (neg index) +79.03% | |
first (neg index) +79.83% | |
out of bound +83.38% | |
last (neg index) +203.98% | |
## :"struct_big (100000 elem), slice_count: 1" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
first (neg index) -88.30% | |
middle (neg index) -69.85% | |
last (neg index) -54.72% | |
last -25.68% | |
middle -23.42% | |
first +6.39% | |
## :"list_huge (500000 elem), slice_count: 990" | |
last -1.77% | |
middle (neg index) -0.55% | |
first -0.50% | |
first (neg index) -0.22% | |
out of bound (neg index) +0.59% | |
out of bound +1.78% | |
last (neg index) +3.91% | |
middle +44.45% | |
## :"list_empty (0 elem), slice_count: 990" | |
first (neg index) +75.77% | |
first +103.51% | |
middle +104.19% | |
middle (neg index) +109.41% | |
out of bound (neg index) +111.26% | |
out of bound +120.12% | |
last +123.62% | |
last (neg index) +162.31% | |
## :"range_huge (500000 elem), slice_count: 990" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
last (neg index) -100.00% | |
last -100.00% | |
middle (neg index) -99.93% | |
first (neg index) -99.90% | |
middle -99.63% | |
first -27.12% | |
## :"struct (1000 elem), slice_count: 990" | |
out of bound (neg index) -99.84% | |
out of bound -99.84% | |
last (neg index) -43.23% | |
middle (neg index) -42.17% | |
first (neg index) -36.60% | |
middle -1.51% | |
first +1.34% | |
last +3.37% | |
## :"map_empty (0 elem), slice_count: 0" | |
out of bound -85.77% | |
last -85.69% | |
last (neg index) -85.10% | |
out of bound (neg index) -84.19% | |
first (neg index) -80.29% | |
middle (neg index) -79.03% | |
first -78.50% | |
middle -78.41% | |
## :"list (1000 elem), slice_count: 1" | |
middle -39.52% | |
last -26.12% | |
last (neg index) -21.70% | |
middle (neg index) -14.24% | |
out of bound +6.12% | |
out of bound (neg index) +6.42% | |
first +14.82% | |
first (neg index) +15.11% | |
## :"list (1000 elem), slice_count: 0" | |
last (neg index) -96.57% | |
middle (neg index) -96.52% | |
out of bound -96.42% | |
first (neg index) -96.37% | |
out of bound (neg index) -96.31% | |
middle -22.46% | |
last -15.29% | |
first -9.71% | |
## :"map_single (1 elem), slice_count: 100" | |
out of bound (neg index) -55.26% | |
out of bound -52.70% | |
last (neg index) +41.51% | |
last +44.31% | |
middle +50.80% | |
middle (neg index) +50.91% | |
first (neg index) +52.41% | |
first +55.91% | |
## :"map_huge (500000 elem), slice_count: 0" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
middle (neg index) -100.00% | |
middle -100.00% | |
last (neg index) -100.00% | |
last -100.00% | |
first (neg index) -100.00% | |
first -100.00% | |
## :"list_huge (500000 elem), slice_count: 0" | |
out of bound (neg index) -99.99% | |
out of bound -99.99% | |
middle (neg index) -99.99% | |
last (neg index) -99.99% | |
first (neg index) -99.99% | |
last -24.48% | |
middle -21.27% | |
first -13.75% | |
## :"range_single (1 elem), slice_count: 100" | |
out of bound (neg index) -68.03% | |
out of bound -61.61% | |
first (neg index) +64.36% | |
middle +65.10% | |
last (neg index) +89.54% | |
middle (neg index) +116.77% | |
first +127.50% | |
last +129.01% | |
## :"list_huge (500000 elem), slice_count: 1" | |
last (neg index) -18.64% | |
last -18.45% | |
middle (neg index) -11.21% | |
out of bound (neg index) -2.06% | |
first (neg index) -0.52% | |
out of bound +0.10% | |
middle +16.85% | |
first +46.53% | |
## :"map_empty (0 elem), slice_count: 990" | |
out of bound -41.99% | |
out of bound (neg index) -41.27% | |
last -40.67% | |
last (neg index) -39.43% | |
middle (neg index) +41.34% | |
first +41.93% | |
first (neg index) +49.22% | |
middle +56.39% | |
## :"range_big (100000 elem), slice_count: 100" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
last (neg index) -99.99% | |
last -99.98% | |
middle (neg index) -99.93% | |
first (neg index) -99.93% | |
middle -99.77% | |
first -3.96% | |
## :"list_big (100000 elem), slice_count: 990" | |
first -6.34% | |
last (neg index) -1.85% | |
out of bound (neg index) -1.39% | |
first (neg index) -0.50% | |
out of bound +0.94% | |
middle (neg index) +3.38% | |
last +6.72% | |
middle +29.36% | |
## :"range (1000 elem), slice_count: 100" | |
out of bound -99.80% | |
out of bound (neg index) -99.78% | |
last (neg index) -98.96% | |
last -98.85% | |
middle (neg index) -93.54% | |
first (neg index) -91.53% | |
middle -82.74% | |
first +0.27% | |
## :"list_big (100000 elem), slice_count: 0" | |
out of bound (neg index) -99.96% | |
out of bound -99.96% | |
middle (neg index) -99.96% | |
last (neg index) -99.96% | |
first (neg index) -99.96% | |
middle -25.51% | |
last -24.95% | |
first -17.87% | |
## :"struct_empty (0 elem), slice_count: 100" | |
out of bound -63.13% | |
out of bound (neg index) -49.91% | |
last -49.18% | |
last (neg index) -48.63% | |
middle (neg index) +26.17% | |
first +39.01% | |
middle +40.95% | |
first (neg index) +46.12% | |
## :"list (1000 elem), slice_count: 990" | |
first -29.87% | |
middle (neg index) -0.59% | |
last +0.01% | |
last (neg index) +1.18% | |
out of bound (neg index) +5.68% | |
out of bound +8.50% | |
middle +17.27% | |
first (neg index) +29.40% | |
## :"map (1000 elem), slice_count: 0" | |
out of bound (neg index) -99.97% | |
out of bound -99.97% | |
middle (neg index) -99.97% | |
last (neg index) -99.97% | |
first (neg index) -99.97% | |
last -99.96% | |
middle -99.92% | |
first -99.79% | |
## :"struct_huge (500000 elem), slice_count: 1" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
first (neg index) -85.81% | |
middle (neg index) -68.76% | |
last (neg index) -55.92% | |
last -19.74% | |
middle -14.49% | |
first +6.95% | |
## :"map_empty (0 elem), slice_count: 1" | |
last (neg index) -40.07% | |
out of bound -34.72% | |
out of bound (neg index) -33.81% | |
last -30.30% | |
middle -16.43% | |
middle (neg index) -15.69% | |
first (neg index) -6.96% | |
first +18.76% | |
## :"list_single (1 elem), slice_count: 990" | |
middle (neg index) +63.39% | |
first +70.90% | |
out of bound +78.91% | |
out of bound (neg index) +79.00% | |
last +85.65% | |
middle +91.82% | |
first (neg index) +92.48% | |
last (neg index) +140.38% | |
## :"map_huge (500000 elem), slice_count: 990" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
first (neg index) -83.64% | |
middle (neg index) -63.36% | |
last (neg index) -45.19% | |
last +0.81% | |
middle +1.97% | |
first +4.75% | |
## :"range_huge (500000 elem), slice_count: 0" | |
out of bound (neg index) -100.00% | |
out of bound -100.00% | |
middle (neg index) -100.00% | |
middle -100.00% | |
last (neg index) -100.00% | |
last -100.00% | |
first (neg index) -100.00% | |
first -87.34% | |
## :"map (1000 elem), slice_count: 990" | |
out of bound (neg index) -99.88% | |
out of bound -99.88% | |
middle (neg index) -45.12% | |
first (neg index) -44.26% | |
last (neg index) -41.28% | |
first -2.82% | |
last +0.35% | |
middle +3.26% | |
## :"list_single (1 elem), slice_count: 100" | |
middle (neg index) +70.88% | |
first (neg index) +88.78% | |
middle +90.24% | |
last +90.76% | |
first +93.57% | |
out of bound +108.41% | |
out of bound (neg index) +110.80% | |
last (neg index) +252.79% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule EnumSlice.Original do | |
def slice(enumerable, first..last) when first >= 0 and last >= 0 do | |
# Simple case, which works on infinite enumerables | |
if last - first >= 0 do | |
slice(enumerable, first, last - first + 1) | |
else | |
[] | |
end | |
end | |
def slice(enumerable, first..last) do | |
{list, count} = enumerate_and_count(enumerable, 0) | |
corr_first = if first >= 0, do: first, else: first + count | |
corr_last = if last >= 0, do: last, else: last + count | |
length = corr_last - corr_first + 1 | |
if corr_first >= 0 and length > 0 do | |
slice(list, corr_first, length) | |
else | |
[] | |
end | |
end | |
def slice(enumerable, start, count) | |
when is_integer(start) and start < 0 and is_integer(count) and count >= 0 do | |
{list, new_start} = enumerate_and_count(enumerable, start) | |
if new_start >= 0 do | |
slice(list, new_start, count) | |
else | |
[] | |
end | |
end | |
def slice(enumerable, start, count) | |
when is_list(enumerable) and | |
is_integer(start) and start >= 0 and | |
is_integer(count) and count >= 0 do | |
do_slice(enumerable, start, count) | |
end | |
def slice(enumerable, start, count) | |
when is_integer(start) and start >= 0 and is_integer(count) and count >= 0 do | |
{_, _, list} = Enumerable.reduce(enumerable, | |
{:cont, {start, count, []}}, fn | |
_entry, {start, count, _list} when start > 0 -> | |
{:cont, {start-1, count, []}} | |
entry, {start, count, list} when count > 1 -> | |
{:cont, {start, count-1, [entry | list]}} | |
entry, {start, count, list} -> | |
{:halt, {start, count, [entry | list]}} | |
end) |> elem(1) | |
:lists.reverse(list) | |
end | |
## slice | |
defp do_slice([], _start, _count) do | |
[] | |
end | |
defp do_slice(_list, _start, 0) do | |
[] | |
end | |
defp do_slice([h | t], 0, count) do | |
[h | do_slice(t, 0, count-1)] | |
end | |
defp do_slice([_ | t], start, count) do | |
do_slice(t, start-1, count) | |
end | |
defp enumerate_and_count(enumerable, count) when is_list(enumerable) do | |
{enumerable, length(enumerable) - abs(count)} | |
end | |
defp enumerate_and_count(enumerable, count) do | |
Enum.map_reduce(enumerable, -abs(count), fn(x, acc) -> {x, acc + 1} end) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule EnumSlice.Rewritten do | |
require Logger | |
@type t :: Enumerable.t | |
@type element :: any | |
@type index :: integer | |
@type default :: any | |
@spec slice(t, Range.t) :: list | |
def slice(enumerable, range) | |
def slice(enumerable, start..finish), | |
do: do_slice(enumerable, {start, finish}) | |
defp do_slice(enumerable, {start, start}) do | |
case fetch(enumerable, start) do | |
:error -> | |
[] | |
{:ok, result} -> | |
[result] | |
end | |
end | |
defp do_slice(_enumerable, {start, finish}) | |
when start > finish and ((start >= 0 and finish >= 0) or (start < 0 and finish < 0)) do | |
[] | |
end | |
defp do_slice(enumerable, {start, finish}) when start < 0 or finish < 0 do | |
case get_size_index(enumerable, start) do | |
:error -> | |
[] | |
{:ok, size, normalized_start} -> | |
case normalize_index(finish, size) do | |
:error -> | |
[] | |
normalized_finish -> | |
do_slice(enumerable, {normalized_start, normalized_finish}) | |
end | |
{:error, _module} -> | |
case enumerate_count_index(enumerable, start) do | |
:error -> | |
[] | |
{:ok, list, count, normalized_start} -> | |
case normalize_index(finish, count) do | |
:error -> | |
[] | |
normalized_finish -> | |
do_slice(list, {normalized_start, normalized_finish}) | |
end | |
end | |
end | |
end | |
defp do_slice(enumerable, {start, finish}) when is_list(enumerable) do | |
count = finish - start + 1 | |
slice_list(enumerable, start, count) | |
end | |
defp do_slice(first..last, {start, finish}) do | |
slice_range({first, last}, {start, finish}) | |
end | |
defp do_slice(enumerable, {start, finish}) do | |
slice_enumerable(enumerable, {start, finish}) | |
end | |
@spec slice(t, index, non_neg_integer) :: t | |
def slice(enumerable, start, n) when is_integer(start) and is_integer(n) and n >= 0, | |
do: do_slice(enumerable, start, n) | |
defp do_slice(_enumerable, _start, 0), | |
do: [] | |
defp do_slice(enumerable, start, n) when start < 0 do | |
case get_size_index(enumerable, start) do | |
:error -> | |
[] | |
{:error, _module} -> | |
case enumerate_count_index(enumerable, start) do | |
:error -> | |
[] | |
{:ok, list, count, normalized_start} -> | |
finish = normalized_start + n - 1 | |
case normalize_index(finish, count) do | |
:error -> | |
[] | |
normalized_finish -> | |
do_slice(list, {normalized_start, normalized_finish}) | |
end | |
end | |
{:ok, size, normalized_start} -> | |
finish = normalized_start + n - 1 | |
case normalize_index(finish, size) do | |
:error -> | |
[] | |
normalized_finish -> | |
do_slice(enumerable, {normalized_start, normalized_finish}) | |
end | |
end | |
end | |
defp do_slice(enumerable, start, n) do | |
finish = start + n - 1 | |
do_slice(enumerable, {start, finish}) | |
end | |
################################ | |
def fetch(first..last, index) when is_integer(index) do | |
fetch_range(first, last, index) | |
end | |
def fetch(enumerable, index) when is_integer(index) and index < 0 do | |
case enumerable do | |
enumerable when is_list(enumerable) -> | |
enumerable | |
|> :lists.reverse | |
|> fetch_list((-index) - 1) | |
_ -> | |
case Enumerable.count(enumerable) do | |
{:error, _} -> | |
enumerable | |
|> Enum.reverse | |
|> fetch_list((-index) - 1) | |
{:ok, count} when (count + index) < 0 -> | |
:error | |
{:ok, count} -> | |
fetch_enumerable(enumerable, count + index, Enumerable) | |
end | |
end | |
end | |
def fetch(enumerable, index) when is_list(enumerable) and is_integer(index) do | |
fetch_list(enumerable, index) | |
end | |
def fetch(enumerable, index) when is_integer(index) do | |
count_result = | |
case Enumerable.count(enumerable) do | |
{:error, module} -> | |
{:ok, module} | |
{:ok, count} when count <= index -> | |
:error | |
{:ok, _} -> | |
{:ok, Enumerable} | |
end | |
case count_result do | |
:error -> | |
:error | |
{:ok, module} -> | |
fetch_enumerable(enumerable, index, module) | |
end | |
end | |
defp fetch_enumerable(enumerable, index, module) do | |
reduce_result = | |
module.reduce(enumerable, {:cont, 0}, fn | |
entry, ^index -> | |
{:halt, entry} | |
_entry, acc -> | |
{:cont, acc + 1} | |
end) | |
case reduce_result do | |
{:halted, entry} -> {:ok, entry} | |
{:done, _} -> :error | |
end | |
end | |
## Helpers | |
## fetch | |
defp fetch_list([], _index), | |
do: :error | |
defp fetch_list([head | _], 0), | |
do: {:ok, head} | |
defp fetch_list([_ | tail], index), | |
do: fetch_list(tail, index - 1) | |
defp fetch_range(first, last, index) when first <= last and index >= 0 do | |
item = first + index | |
if item > last, do: :error, else: {:ok, item} | |
end | |
defp fetch_range(first, last, index) when first <= last do | |
item = last + index + 1 | |
if item < first, do: :error, else: {:ok, item} | |
end | |
defp fetch_range(first, last, index) when index >= 0 do | |
item = first - index | |
if item < last, do: :error, else: {:ok, item} | |
end | |
defp fetch_range(first, last, index) do | |
item = last - index - 1 | |
if item > first, do: :error, else: {:ok, item} | |
end | |
## slice | |
defp slice_list([], _start, _count), | |
do: [] | |
defp slice_list(_list, _start, 0), | |
do: [] | |
defp slice_list([head | tail], 0, count), | |
do: [head | slice_list(tail, 0, count - 1)] | |
defp slice_list([_ | tail], start, count), | |
do: slice_list(tail, start - 1, count) | |
defp slice_range({first, last}, {start, finish}) do | |
count = last - first + 1 | |
corrected_finish = if finish > count - 1, do: count - 1, else: finish | |
with {:ok, sliced_first} <- fetch_range(first, last, start), | |
{:ok, sliced_last} <- fetch_range(first, last, corrected_finish) | |
do | |
sliced_last..sliced_first |> Enum.reverse | |
else | |
_ -> [] | |
end | |
end | |
defp slice_enumerable(enumerable, {start, finish}) do | |
count = finish - start + 1 | |
{_, _, list} = Enumerable.reduce(enumerable, | |
{:cont, {start, count, []}}, fn | |
_entry, {start, count, _list} when start > 0 -> | |
{:cont, {start-1, count, []}} | |
entry, {start, count, list} when count > 1 -> | |
{:cont, {start, count-1, [entry | list]}} | |
entry, {start, count, list} -> | |
{:halt, {start, count, [entry | list]}} | |
end) |> elem(1) | |
:lists.reverse(list) | |
end | |
defp enumerate_count_index(enumerable, index) when is_list(enumerable) do | |
length = length(enumerable) | |
case normalize_index(index, length) do | |
i when is_integer(i) and i < length -> | |
{:ok, enumerable, length, i} | |
_ -> | |
:error | |
end | |
end | |
defp enumerate_count_index(enumerable, index) do | |
case get_size_index(enumerable, index) do | |
:error -> | |
:error | |
{:error, _module} -> | |
{list, count} = Enum.map_reduce(enumerable, 0, fn(x, acc) -> {x, acc + 1} end) | |
case normalize_index(index, count) do | |
i when is_integer(i) and i < count -> | |
{:ok, list, count, i} | |
_ -> | |
:error | |
end | |
{:ok, size, normalized_index} -> | |
{:ok, Enum.to_list(enumerable), size, normalized_index} | |
end | |
end | |
# Given an enumerable and an index, it returns: | |
# - `{:ok, size, normalized_index}` where normalized_index is an index withing bounds | |
# and zero or positive. | |
# - `:error` if the given index is out of bound | |
# - `{:error, module}` if Enumerable.count/1 is not implemented. | |
defp get_size_index(enumerable, index) do | |
with {:ok, size} <- Enumerable.count(enumerable), | |
normalized_index when normalized_index < size <- normalize_index(index, size) | |
do | |
{:ok, size, normalized_index} | |
else | |
:error -> | |
:error | |
{:error, module} -> | |
{:error, module} | |
end | |
end | |
defp normalize_index(index, count, default \\ :error) do | |
normalized_index = if index >= 0, do: index, else: count + index | |
if normalized_index >= 0, do: normalized_index, else: default | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment