Skip to content

hashString causing poor performance #1212

@adamschackart

Description

@adamschackart

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions