forked from tarcieri/reia
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Note: erlang files from test/benchmarks/ have to be manually compiled and moved to ebin/ folder
- Loading branch information
Showing
10 changed files
with
128 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-module (doloops_benchmark). | ||
|
||
-export ([run/0]). | ||
|
||
run() -> | ||
% TODO: a better way to test loop? | ||
List = lists:seq(0, 1000000), | ||
loop(List). | ||
|
||
loop([], Result) -> | ||
Result; | ||
|
||
loop([H|T], Result) -> | ||
loop(T, [H | Result]). | ||
|
||
loop([H|T]) -> | ||
loop(T, [H]). |
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,9 @@ | ||
module DoloopsBenchmark | ||
def run | ||
range = 1..1000000 | ||
list = range.to_list() | ||
list.map do |n| | ||
n | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-module (forloops_benchmark). | ||
|
||
-export ([run/0]). | ||
|
||
run() -> | ||
% TODO: a better way to test loop? | ||
List = lists:seq(0, 1000000), | ||
loop(List). | ||
|
||
loop([], Result) -> | ||
Result; | ||
|
||
loop([H|T], Result) -> | ||
loop(T, [H | Result]). | ||
|
||
loop([H|T]) -> | ||
loop(T, [H]). |
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,7 @@ | ||
module ForloopsBenchmark | ||
def run | ||
range = 1..1000000 | ||
#list = range.to_list() # Note: weird thing happens when you uncoment this, it affects the speed of the NEXT test drastically | ||
[ n for n in range ] | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-module (recursion_benchmark). | ||
|
||
-export ([run/0]). | ||
|
||
run() -> | ||
loop(1000000). | ||
|
||
loop(0) -> | ||
ok; | ||
|
||
loop(N) -> | ||
loop(N - 1). |
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,14 @@ | ||
module RecursionBenchmark | ||
def loop(0) | ||
:ok | ||
end | ||
|
||
def loop(n) | ||
k = n - 1 | ||
loop(k) | ||
end | ||
|
||
def run | ||
loop(1000000) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-module (sleep_benchmark). | ||
|
||
-export ([run/0]). | ||
|
||
|
||
run() -> | ||
timer:sleep(1000). |
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,5 @@ | ||
module SleepBenchmark | ||
def run | ||
erl.timer.sleep(1000) | ||
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
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