Running the following Wren code:
for (i in 0...10) {
var start = System.clock
var s = []
for (j in 0...100000) {
s.add(" ")
}
s.join()
System.print("%(i) %(System.clock - start)")
}
I get ~10 seconds per iteration on an M4 Mac Mini. When making the following change to wren_value.c:
static void hashString(ObjString* string)
{
string->hash = 0;
}
I get ~1 second per iteration. Hashes seem to be generated for each new string, whereas in other language (such as Python), they're generated on demand.
Running the following Wren code:
I get ~10 seconds per iteration on an M4 Mac Mini. When making the following change to
wren_value.c:I get ~1 second per iteration. Hashes seem to be generated for each new string, whereas in other language (such as Python), they're generated on demand.