|
/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]" |
|
|