Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Running map implementations on a large list to see memory consumption
list = Enum.to_list(1..100_000_000)
MyMap.map_body(list, fn(i) -> i + 1 end)
list = Enum.to_list(1..100_000_000)
MyMap.map_tco(list, fn(i) -> i + 1 end)
tobi@happy ~/github/elixir_playground $ /usr/bin/time -v mix run scripts/tco_list.exs
Command being timed: "mix run scripts/tco_list.exs"
User time (seconds): 10.00
System time (seconds): 1.21
Percent of CPU this job got: 99%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:11.22
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 13052492
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 33
Minor (reclaiming a frame) page faults: 112706
Voluntary context switches: 20743
Involuntary context switches: 1006
Swaps: 0
File system inputs: 13088
File system outputs: 24
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
tobi@happy ~/github/elixir_playground $ /usr/bin/time -v mix run scripts/no_tco_list.exs
Command being timed: "mix run scripts/no_tco_list.exs"
User time (seconds): 9.02
System time (seconds): 0.83
Percent of CPU this job got: 100%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:09.81
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 11511968
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 1
Minor (reclaiming a frame) page faults: 40774
Voluntary context switches: 20006
Involuntary context switches: 122
Swaps: 0
File system inputs: 8
File system outputs: 24
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.