Skip to content

Performance issues with object property lookup #245

@HarlonWang

Description

@HarlonWang
const a = {}
for (let i = 0; i < 10000000; i++) {
    a[i] = i
}

const start = new Date().getTime()
a[1]
console.log("cost:", (new Date().getTime() - start), "ms")

The cost time between QuickJS and V8 (Node) when running the above code.
quickjs: 83 ms
v8: 1 ms

Object property queries under QuickJS still take a relatively long time, I would like to understand the reason for this performance gap, and whether there are any optimization strategies. Additionally, when I changed the object to an array, I was able to save about half of the time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions