You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*This is a fork of [JakubOnderka/simdjson_php](https://github.com/JakubOnderka/simdjson_php) (which is a fork of [crazyxman/simdjson_php](https://github.com/crazyxman/simdjson_php)), which adds JSON
11
+
encoding support with new optimisations.*
8
12
9
-
## Performance Comparison: How Fast is simdjson_php?
13
+
Since the [simdjson](https://pecl.php.net/package/simdjson) PECL extension seems to be unmaintained, or at least slow
14
+
to [accept PRs for improvements](https://github.com/crazyxman/simdjson_php/pulls), we packaged this up under a new
15
+
name (`simdjson_plus`) to avoid conflicts and published it on Packagist (instead of PECL).
| Encode (pretty print) | 0.83 ms | 0.31 ms |**2.6×**|
25
+
| Validate | 1.37 ms | 0.22 ms |**6.2×**|
26
+
| Count items | 1.51 ms | 0.16 ms |**9.4×**|
19
27
20
28
Tests were conducted using PHP 8.3 on an [Apple M1 Max](https://en.wikipedia.org/wiki/Apple_M1#M1_Pro_and_M1_Max). For test specification see `TwitterDecodeBench.php` and `TwitterEncoderBench.php`.
21
29
22
-
Additionally, simdjson_php reduces memory usage compared to `json_decode()`. For example, when decoding twitter.json, memory consumption drops from 3.01 MB to 2.47 MB due to efficient array key deduplication.
30
+
Additionally, simdjson_plus reduces memory usage compared to `json_decode()`. For example, when decoding twitter.json, memory consumption drops from 3.01 MB to 2.47 MB due to efficient array key deduplication.
31
+
32
+
## Related SIMD-accelerated PHP extensions
33
+
*[crc_fast](https://packagist.org/packages/awesome/crc_fast) PHP extension for SIMD-accelerated CRC calculations
34
+
at >100GiB/s.
35
+
*[simdutf](https://packagist.org/packages/awesome/simdutf) PHP extension for Unicode validation and transcoding at
36
+
billions of characters per second using the [simdutf](https://github.com/simdutf/simdutf) project.
23
37
24
-
## Requirement
38
+
## Requirements
25
39
26
-
* PHP 8.0+ (PHP 8.2+ recommended for maximum performance)
40
+
* PHP 8.1+ (PHP 8.2+ recommended for maximum performance)
27
41
* g++ (version 7 or better) or clang++ (version 6 or better)
28
42
* A 64-bit system with a command-line shell (e.g., Linux, macOS, FreeBSD)
29
43
44
+
## Changes
45
+
46
+
See the [change log](CHANGELOG.md).
47
+
48
+
## Installing
49
+
50
+
Use [Composer](https://getcomposer.org) to install this library using [PIE](https://github.com/php/pie):
51
+
52
+
```bash
53
+
composer install awesome/simdjson-plus
54
+
```
55
+
30
56
## Compilation Instructions for Linux
31
57
32
-
To compile simdjson_php, run the following commands:
58
+
To compile simdjson_plus, run the following commands:
33
59
34
60
```bash
35
61
phpize
@@ -42,7 +68,7 @@ make install
42
68
Once installed, add this line to your `php.ini` file:
43
69
44
70
```ini
45
-
extension=simdjson.so
71
+
extension=simdjson_plus.so
46
72
```
47
73
48
74
## Usage Examples
@@ -141,7 +167,7 @@ You can also use base64url encoding (RFC 4648 §5) by setting second argument to
141
167
142
168
### Encode to stream
143
169
144
-
For large data sets, simdjson_php provides the `simdjson_encode_to_stream()` function to save data directly to a file or output buffer.
170
+
For large data sets, simdjson_plus provides the `simdjson_encode_to_stream()` function to save data directly to a file or output buffer.
145
171
146
172
```php
147
173
$bigStructure = [...];
@@ -174,4 +200,4 @@ simdjson_decode_from_stream(fopen("php://input", "r")); // send by user
174
200
```
175
201
176
202
## Benchmarks
177
-
See the [benchmark](./benchmark) folder for more benchmarks.
203
+
See the [benchmark](./benchmark) folder for more benchmarks.
0 commit comments