Skip to content

Commit 24f9293

Browse files
committed
chore: update README
1 parent 6cafc87 commit 24f9293

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,23 +181,23 @@ const updatedAt = updatedAtColumn[rowIndex];
181181

182182
## Benchmark
183183

184-
**Test:** transfer 100 000 rows (5 columns) from C++ to JS and read every value.
184+
**Test:** 10 000 iterations — each call transfers N rows (5 columns) from C++ to JS and reads one row.
185185

186186
```
187187
Schema: id (int32) | status (uint8) | isActive (uint8) | createdAt (double) | updatedAt (double)
188-
Rows: 100 000
188+
Iterations: 10 000
189189
```
190190

191-
| Approach | Time |
192-
|-----------------------|------------|
193-
| Array of objects | ~2079.81 ms |
194-
| **react-native-columnar** | **~22.06 ms** |
191+
| Rows | Array of objects | react-native-columnar | Speedup |
192+
|------|------------------|-----------------------|----------|
193+
| 100 | ~418.81 ms | **~14.96 ms** | **27×** |
194+
| 500 | ~2079.81 ms | **~22.06 ms** | **94×** |
195+
| 1000 | ~4360.11 ms | **~35.89 ms** | **121×** |
196+
| 2000 | ~9444.47 ms | **~45.39 ms** | **208×** |
195197

196-
### **94× faster**
198+
**Array of objects** — each call allocates a JS array of objects with 5 keys each, boxes every value, and puts pressure on the GC — multiplied across 10 000 iterations.
197199

198-
**Array of objects** — each row is a JS object `{ id, status, isActive, createdAt, updatedAt }`. The JS engine allocates 100 000 objects with 5 keys each, boxes every value, and puts significant pressure on the GC.
199-
200-
**react-native-columnar** — one binary buffer is allocated in C++, all 100 000 rows are written in a single loop, and the buffer pointer is handed to the JS engine as an `ArrayBuffer`. The JS side creates five typed array views (`Int32Array`, `Uint8Array`, `Float64Array`) over the same memory — **zero copies, zero parsing, zero object allocation**.
200+
**react-native-columnar** — one binary buffer is allocated in C++, all rows are written in a single loop, and the buffer pointer is handed to the JS engine as an `ArrayBuffer`. The JS side creates five typed array views (`Int32Array`, `Uint8Array`, `Float64Array`) over the same memory — **zero copies, zero parsing, zero object allocation**.
201201

202202
> Measured on iPhone 16 Pro. Results will vary by device and data shape.
203203

example/ios/JSITest.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#import "React/RCTBridgeModule.h"
1515
#import "jsi/jsi.h"
1616
#include "react/bridging/Bridging.h"
17-
#include <react-native-columnar/react-native-columnar.h>
17+
#include "react-native-columnar.h"
1818

1919
#define MY_COLUMNS(X) \
2020
X(int32_t, id) \
@@ -92,7 +92,7 @@ void init_module(jsi::Runtime* runtime) {
9292
[](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
9393
size_t count) {
9494

95-
constexpr const uint32_t rows = 500;
95+
constexpr const uint32_t rows = 100;
9696

9797
jsi::Array array(rt, rows);
9898

@@ -117,7 +117,7 @@ void init_module(jsi::Runtime* runtime) {
117117
[](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
118118
size_t count) {
119119

120-
constexpr uint32_t rows = 500;
120+
constexpr uint32_t rows = 100;
121121

122122
ColumnarWriterBuilder<RowsStruct> builder(rows);
123123
auto cols = RowsStruct::createColumns(builder);

0 commit comments

Comments
 (0)