Numbered Steps to Reproduce Problem:
Code Snippet (if applicable) to Reproduce Problem:
/proc/main()
var/list/L = list()
// === Change 1000 to however big you want your list ===
for (var/i in 1 to 1000)
L += i
sleep(1)
var/count = 0
var/start = world.tick_usage
while (world.tick_usage - start < 100)
count += 1
// === Uncomment whichever one you want to test ===
// json_encode(L)
// L.Join("-")
world.log << count
Expected Results:
Join() would be as fast, or faster, than json_encode, as it should have to do significantly less work.
Actual Results:
In 0.1s, both functions perform this number of calls:
Empty list (Join is 66% faster):
- json_encode(L): 134,474
- L.Join("-"): 223,724
One entry (Join is 15% slower):
- json_encode(L): 114,873
- L.Join("-"): 99,524
Five entries (Join is 18% slower):
- json_encode(L): 57,195
- L.Join("-"): 48,386
1,000 entries (Join is 72% slower):
- json_encode(L): 624
- L.Join("-"): 361