Created
September 23, 2018 21:29
-
-
Save MrStonedOne/5e732954813cc21411db32fe1b7c3b0c to your computer and use it in GitHub Desktop.
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
Sample Size = 100000 | |
List of lists, before fill: 824kb - 8.44b | |
List of lists, after fill: 3.98mb - 41.74b | |
List of datums, before fill: 784kb - 8.03b | |
List of datums, after fill: 3.86mb - 40.47b | |
List of strings, before fill: 784kb - 8.03b | |
List of strings, after fill: 15.66mb - 164.21b | |
Assoicated list of strings, before fill: 784kb - 8.03b | |
Assoicated list of strings, after fill: 18.43mb - 193.29b |
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
/proc/getmem() | |
return text2num(call("bmem.dll", "mem")()) | |
#define SAMPLE_SIZE 100000 | |
/client/verb/memorytest() | |
var/startingmemory = getmem() | |
var/list/lists = new (SAMPLE_SIZE) | |
var/listemptymemory = getmem() | |
for (var/i in 1 to lists.len) | |
lists[i] = list() | |
var/listfullmemory = getmem() | |
var/list/datums = new (SAMPLE_SIZE) | |
var/datumemptymemory = getmem() | |
for (var/i in 1 to datums.len) | |
datums[i] = new /datum() | |
var/datumfullmemory = getmem() | |
var/list/slists = new (SAMPLE_SIZE) | |
var/slistemptymemory = getmem() | |
for (var/i in 1 to slists.len) | |
slists[i] = num2text(rand(1,(2**24))*rand(), 99) | |
var/slistfullmemory = getmem() | |
var/list/salists = new (SAMPLE_SIZE) | |
var/salistemptymemory = getmem() | |
for (var/i in 1 to salists.len) | |
var/key = num2text(rand(1,(2**24))*rand(), 99) | |
salists[i] = key | |
salists[key] = rand(1,(2**24))*rand() | |
var/salistfullmemory = getmem() | |
world << "Sample Size = [SAMPLE_SIZE]" | |
world << "List of lists, before fill: [standardizesize(listemptymemory - startingmemory)] - [standardizesize((listemptymemory - startingmemory)/SAMPLE_SIZE)]" | |
world << "List of lists, after fill: [standardizesize(listfullmemory - listemptymemory)] - [standardizesize((listfullmemory - listemptymemory)/SAMPLE_SIZE)]" | |
world << "List of datums, before fill: [standardizesize(datumemptymemory - listfullmemory)] - [standardizesize((datumemptymemory - listfullmemory)/SAMPLE_SIZE)]" | |
world << "List of datums, after fill: [standardizesize(datumfullmemory - datumemptymemory)] - [standardizesize((datumfullmemory - datumemptymemory)/SAMPLE_SIZE)]" | |
world << "List of strings, before fill: [standardizesize(slistemptymemory - datumfullmemory)] - [standardizesize((slistemptymemory - datumfullmemory)/SAMPLE_SIZE)]" | |
world << "List of strings, after fill: [standardizesize(slistfullmemory - slistemptymemory)] - [standardizesize((slistfullmemory - slistemptymemory)/SAMPLE_SIZE)]" | |
world << "Assoicated list of strings, before fill: [standardizesize(salistemptymemory - slistfullmemory)] - [standardizesize((salistemptymemory - slistfullmemory)/SAMPLE_SIZE)]" | |
world << "Assoicated list of strings, after fill: [standardizesize(salistfullmemory - salistemptymemory)] - [standardizesize((salistfullmemory - salistemptymemory)/SAMPLE_SIZE)]" | |
/proc/standardizesize(size) | |
var/append = "b" | |
if (size > 2048) | |
append = "kb" | |
size /= 1024 | |
if (size > 2048) | |
append = "mb" | |
size /= 1024 | |
if (size > 2048) | |
append = "gb" | |
size /= 1024 | |
return "[round(size, 0.01)][append]" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment