-
Notifications
You must be signed in to change notification settings - Fork 3
/
try_me.exs
35 lines (26 loc) · 1.26 KB
/
try_me.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
alias Primes.Helper.Timer
#max_prime = 100_000
#max_prime = 15_485_863 # one million primes
max_prime = 32_452_843 # two millions primes
IO.puts("\nSieve Of Eratosthenes: Erlang array")
{time, array_result} = Timer.run(Primes.SieveOfEratosthenes.Array, :get_primes_list, [max_prime])
IO.puts("Time: #{time} sec.")
IO.inspect(array_result)
IO.puts("\nSieve Of Eratosthenes: Elixir MapSet")
{time, mapset_result} = Timer.run(Primes.SieveOfEratosthenes.MapSet, :get_primes_list, [max_prime])
IO.puts("Time: #{time} sec.")
IO.inspect(mapset_result)
# IO.puts("\nSieve Of Eratosthenes: Elixir List")
# {time, list_result} = Timer.run(Primes.SieveOfEratosthenes.List, :get_primes_list, [max_prime])
# IO.puts("Time: #{time} sec.")
# IO.inspect(list_result)
IO.puts("\nSieve Of Eratosthenes: Erlang ETS")
{time, est_result} = Timer.run(Primes.SieveOfEratosthenes.Ets, :get_primes_list, [max_prime])
IO.puts("Time: #{time} sec.")
IO.inspect(est_result)
IO.puts("\nSieve Of Eratosthenes: Elixir Map")
{time, map_result} = Timer.run(Primes.SieveOfEratosthenes.Map, :get_primes_list, [max_prime])
IO.puts("Time: #{time} sec.")
IO.inspect(map_result)
results = array_result == mapset_result and mapset_result == est_result and est_result == map_result
IO.puts("\nResults equal: #{results}")