Skip to content

JSON.stringify() is 3x slower on Hermes than JSC #1008

@summer-wu

Description

@summer-wu

Bug Description

JSON.stringify() is 3x slower on Hermes than JSC.

----hermes
Running JSON.stringify 1000 times cost 7265ms
----jsc
Running JSON.stringify 1000 times cost 1612ms
----node
Running JSON.stringify 1000 times cost 2911ms

Hermes version: 0.11.0
React Native version (if any):0.68.8
OS version (if any): Mac OS 13.3
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): x86_64

Steps To Reproduce

My testing/benchmarking code: https://gist.github.com/summer-wu/030bd287f8a973d66ff1aa71d7e07569

The Expected Behavior

The performance should be similar.

My opinion

Hermes is good at fast-startup, and provides a easy to use debugger(in Flipper).
But when facing some CPU-intensive tasks, it is slower than JSC. For JSON operation, it is 3x slower(JSON.parse is also slower than JSC #811). For RegExp, it is 10x-20x slower(this is why intl polyfill is slow, #495).
Enabling Hermes is worthy when you need a more quick development cycle, but be aware of those drawbacks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions