Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
byond memory usage of lists vs datums
//run verb, give it its memory usage as it asks, be sure to wait 5 seconds from when it asks to when you enter the data. use process explorer for best results. Use dd -> ds, not direct ds run, re-launch dd between tests
#define SAMPLE_SIZE 1000000
/client/verb/memorytest()
var/startingmemory = input("memory usage (kb)") as num
var/list/lists = new (SAMPLE_SIZE)
var/listemptymemory = input("memory usage (kb)") as num
for (var/i in 1 to lists.len)
lists[i] = list()
var/listfullmemory = input("memory usage (kb)") as num
var/list/datums = new (SAMPLE_SIZE)
var/datumemptymemory = input("memory usage(kb)") as num
for (var/i in 1 to datums.len)
datums[i] = new /datum()
var/datumfullmemory = input("memory usage(kb)") as num
world << "Memory usage of list of lists with [num2text(SAMPLE_SIZE,99)] null values [num2text(listemptymemory - startingmemory, 99)]kb ([num2text((listemptymemory - startingmemory)/SAMPLE_SIZE*1024, 99)] bytes per unit)"
world << "Memory usage of list of lists with [num2text(SAMPLE_SIZE,99)] list values [num2text(listfullmemory - listemptymemory, 99)]kb ([num2text((listfullmemory - listemptymemory)/SAMPLE_SIZE*1024, 99)] bytes per unit)"
world << "Memory usage of list of datums with [num2text(SAMPLE_SIZE,99)] null values [num2text(datumemptymemory - listfullmemory, 99)]kb ([num2text((datumemptymemory - listfullmemory)/SAMPLE_SIZE*1024, 99)] bytes per unit)"
world << "Memory usage of list of datums with [num2text(SAMPLE_SIZE,99)] datum values [num2text(datumfullmemory - datumemptymemory, 99)]kb ([num2text((datumfullmemory - datumemptymemory)/SAMPLE_SIZE*1024, 99)] bytes per unit)"
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.