11## Benchmarks
22
3+ _ = Application . start ( :telemetry )
4+
35defmodule BenchCache do
46 use Nebulex.Cache ,
5- otp_app: :nebulex ,
6- adapter: NebulexRedisAdapter
7+ otp_app: :nebulex ,
8+ adapter: Nebulex.Adapters.Redis
79end
810
911# start caches
@@ -21,26 +23,23 @@ inputs = %{
2123}
2224
2325benchmarks = % {
24- "get" => fn { cache , random } ->
25- cache . get ( random )
26- end ,
27- "get_all" => fn { cache , _random } ->
28- cache . get_all ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] )
26+ "fetch" => fn { cache , random } ->
27+ cache . fetch ( random )
2928 end ,
30- "put" => fn { cache , random } ->
31- cache . put ( random , random )
29+ "put! " => fn { cache , random } ->
30+ cache . put! ( random , random )
3231 end ,
33- "put_new" => fn { cache , random } ->
34- cache . put_new ( random , random )
32+ "put_new! " => fn { cache , random } ->
33+ cache . put_new! ( random , random )
3534 end ,
36- "replace" => fn { cache , random } ->
37- cache . replace ( random , random )
35+ "replace! " => fn { cache , random } ->
36+ cache . replace! ( random , random )
3837 end ,
39- "put_all" => fn { cache , _random } ->
40- cache . put_all ( bulk )
38+ "put_all! " => fn { cache , _random } ->
39+ cache . put_all! ( bulk )
4140 end ,
42- "delete" => fn { cache , random } ->
43- cache . delete ( random )
41+ "delete! " => fn { cache , random } ->
42+ cache . delete! ( random )
4443 end ,
4544 "take" => fn { cache , random } ->
4645 cache . take ( random )
@@ -51,26 +50,29 @@ benchmarks = %{
5150 "ttl" => fn { cache , random } ->
5251 cache . ttl ( random )
5352 end ,
54- "expire" => fn { cache , random } ->
55- cache . expire ( random , 1000 )
53+ "expire! " => fn { cache , random } ->
54+ cache . expire! ( random , 1000 )
5655 end ,
57- "incr" => fn { cache , _random } ->
58- cache . incr ( :counter , 1 )
56+ "incr! " => fn { cache , _random } ->
57+ cache . incr! ( :counter , 1 )
5958 end ,
60- "update" => fn { cache , random } ->
61- cache . update ( random , 1 , & Kernel . + ( & 1 , 1 ) )
59+ "update! " => fn { cache , random } ->
60+ cache . update! ( random , 1 , & Kernel . + ( & 1 , 1 ) )
6261 end ,
63- "get_and_update" => fn { cache , random } ->
64- cache . get_and_update ( random , fn
62+ "get_and_update! " => fn { cache , random } ->
63+ cache . get_and_update! ( random , fn
6564 nil -> { nil , 1 }
6665 val -> { val , val * 2 }
6766 end )
6867 end ,
69- "all" => fn { cache , _random } ->
70- cache . all ( )
68+ "get_all!" => fn { cache , _random } ->
69+ cache . get_all! ( in: [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] )
70+ end ,
71+ "count_all!" => fn { cache , _random } ->
72+ cache . count_all! ( )
7173 end ,
72- "count_all " => fn { cache , _random } ->
73- cache . count_all ( )
74+ "delete_all! " => fn { cache , _random } ->
75+ cache . delete_all! ( in: [ 1 , 2 , 3 ] )
7476 end
7577}
7678
0 commit comments