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
# To avoid making extra gist, I have put all the modules needed for bmark in this gist. | |
# Nevertheless, you need to break them in different .exs files | |
defmodule BigBmark do | |
use Bmark | |
@input Enum.to_list(1..1_000_000) | |
bmark :tail_recursive do | |
map_fun = fn(element) -> element + 1 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
614214 | |
627304 | |
627439 | |
664559 | |
650067 | |
640881 | |
636025 | |
624362 | |
661385 | |
637485 |
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
$ mix bmark.cmp ./results/verybigbmark.tail_recursive.results ./results/verybigbmark.body_recursive.results | |
./results/verybigbmark.tail_recursive.results: ./results/verybigbmark.body_recursive.results: | |
614214 833306 | |
627304 835191 | |
627439 829388 | |
664559 864173 | |
650067 882320 | |
640881 846133 | |
636025 797305 | |
624362 793554 |
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
Benchmark suite executing with the following configuration: | |
warmup: 10.0s | |
time: 20.0s | |
parallel: 1 | |
inputs: big, medium, small, verybig | |
Estimated total run time: 360.0s | |
Benchmarking with input big: | |
Benchmarking body-recursive... |
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
Settings: | |
duration: 1.0 s | |
## BigBench | |
[13:24:55] 1/12: body-recursive | |
[13:24:58] 2/12: std-lib map | |
[13:25:01] 3/12: tail-recursive | |
## MediumBench | |
[13:25:04] 4/12: body-recursive | |
[13:25:06] 5/12: std-lib map |
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
# To avoid making extra gist, I have put all the modules needed for benchfella in this gist. | |
# Nevertheless, you need to break them in different .exs files | |
defmodule SmallBench do | |
use Benchfella | |
setup_all do | |
input = %{map_fun: fn(element) -> element + 1 end, | |
list: Enum.to_list(1..10_000)} | |
{:ok, input} |
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 Benchmark do | |
def run do | |
map_fun = fn(element) -> element + 1 end | |
inputs = %{ | |
"small" => Enum.to_list(1..10_000), | |
"medium" => Enum.to_list(1..100_000), | |
"big" => Enum.to_list(1..1_000_000), | |
"verybig" => Enum.to_list(1..5_000_000) | |
} |
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 MyMap do | |
def map_tco(list, function) do | |
Enum.reverse do_map_tco([], list, function) | |
end | |
defp do_map_tco(acc, [], _function) do | |
acc | |
end | |
defp do_map_tco(acc, [head | tail], func) do | |
do_map_tco([func.(head) | acc], tail, func) | |
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
# openFrameworks OS X makefile | |
# | |
# make help : shows this message | |
# make Debug: makes the application with debug symbols | |
# make Release: makes the app with optimizations | |
# make: the same as make Release | |
# make CleanDebug: cleans the Debug target | |
# make CleanRelease: cleans the Release target | |
# make clean: cleans everything | |
# |