-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#189] Overall cleanup to move adapters to separate repos
- Loading branch information
Showing
73 changed files
with
1,420 additions
and
8,434 deletions.
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
## Benchmarks | ||
|
||
:ok = Application.start(:telemetry) | ||
|
||
defmodule Cache do | ||
@moduledoc false | ||
use Nebulex.Cache, | ||
otp_app: :nebulex, | ||
adapter: Nebulex.Adapters.Nil | ||
end | ||
|
||
benchmarks = %{ | ||
"get" => fn input -> | ||
Cache.get(input) | ||
end, | ||
"get_all" => fn input -> | ||
Cache.get_all([input, "foo", "bar"]) | ||
end, | ||
"put" => fn input -> | ||
Cache.put(input, input) | ||
end, | ||
"put_new" => fn input -> | ||
Cache.put_new(input, input) | ||
end, | ||
"replace" => fn input -> | ||
Cache.replace(input, input) | ||
end, | ||
"put_all" => fn input -> | ||
Cache.put_all([{input, input}, {"foo", "bar"}]) | ||
end, | ||
"delete" => fn input -> | ||
Cache.delete(input) | ||
end, | ||
"take" => fn input -> | ||
Cache.take(input) | ||
end, | ||
"has_key?" => fn input -> | ||
Cache.has_key?(input) | ||
end, | ||
"count_all" => fn _input -> | ||
Cache.count_all() | ||
end, | ||
"ttl" => fn input -> | ||
Cache.ttl(input) | ||
end, | ||
"expire" => fn input -> | ||
Cache.expire(input, 1) | ||
end, | ||
"incr" => fn _input -> | ||
Cache.incr(:counter, 1) | ||
end, | ||
"update" => fn input -> | ||
Cache.update(input, 1, &Kernel.+(&1, 1)) | ||
end, | ||
"all" => fn _input -> | ||
Cache.all() | ||
end | ||
} | ||
|
||
# start local cache | ||
{:ok, local} = Cache.start_link() | ||
|
||
Benchee.run( | ||
benchmarks, | ||
inputs: %{"rand" => 100_000}, | ||
before_each: fn n -> :rand.uniform(n) end, | ||
formatters: [ | ||
{Benchee.Formatters.Console, comparison: false, extended_statistics: true}, | ||
{Benchee.Formatters.HTML, extended_statistics: true, auto_open: false} | ||
], | ||
print: [ | ||
fast_warning: false | ||
] | ||
) | ||
|
||
# stop cache | ||
if Process.alive?(local), do: Supervisor.stop(local) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.