owaisqayum
Benchmark with benchee having separate inputs for same functions
Hi, i am trying to benchmark a function with different input but the results are getting shown in different HTML files.
my code:
map_fun = fn i -> [i, i * i] end
Benchee.run(
%{
"10 values" => fn input -> Enum.flat_map(input, map_fun) end,
"20 values" => fn input -> Enum.flat_map(input, map_fun) end,
"30 values" => fn input -> Enum.flat_map(input, map_fun) end
},
inputs: %{
:ten => 1..10,
:twenty => 1..20,
:thirty => 1..30
},
time: 10,
memory_time: 30,
formatters: [
{Benchee.Formatters.HTML, file: "samples_output/ex/ex.html"},
{Benchee.Formatters.Console, extended_statistics: true}
],
warmup: 30
)
I am getting results but the input :ten gets applied to all three functions in Benchee.run. All I want is to specify which input is for which run. Can I somehow do that with pattern matching?
Also, I don’t want to declare the list above Benchee.run, how can I do it with the help of inputs.
Thanks! ![]()
Marked As Solved
devonestes
In this case, you want to just put the inputs in the function and not use the inputs feature. That’s designed for testing the same inputs against different functions, not for testing the same function against different inputs.
map_fun = fn i -> [i, i * i] end
Benchee.run(
%{
"10 values" => fn input -> Enum.flat_map(0..10, map_fun) end,
"20 values" => fn input -> Enum.flat_map(0..20, map_fun) end,
"30 values" => fn input -> Enum.flat_map(0..30, map_fun) end
},
time: 10,
memory_time: 30,
formatters: [
{Benchee.Formatters.HTML, file: "samples_output/ex/ex.html"},
{Benchee.Formatters.Console, extended_statistics: true}
],
warmup: 30
)
3
Popular in Questions
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Hi everyone,
I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
Hello all!
I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar.
I p...
New
Other popular topics
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
I have an umbrella app.
Some of the apps inside depend on other apps in the umbrella, unsurprisingly.
I’m writing a test for one of the...
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar.
I p...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









