facebook / facebook/hermes

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

Open
#1,008 12 comments 0 reactions 0 assignees View on GitHub
enhancement performance
Dominant language
JavaScript
Stars
11.3k
Forks
859
Avg merge
1h 30m
Merged PRs (30d)
3

Description

## 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.