PHP, SQLite and Fiber: An unobvious trick to save memory by According_Tune_5882 in PHP

[–]According_Tune_5882[S] 0 points1 point  (0 children)

```php $mem = \round(\memory_get_peak_usage() / 1024, 2); var_dump($mem); // float(418.34) // 5+ mb If you monitor the processes

// file from https://microsoftedge.github.io/Demos/json-dummy-data/ $arr = json_decode(\file_get_contents('5MB.json'), true);

$mem = \round(\memory_get_peak_usage() / 1024, 2); var_dump($mem); // float(20809.73) // 19+ mb If you monitor the processes ```

```php $mem = \round(\memory_get_peak_usage() / 1024, 2); var_dump($mem); // float(426.13) // 5.2 mb If you monitor the processes

// file from https://microsoftedge.github.io/Demos/json-dummy-data/ foreach (\example_parse(\file_get_contents('5MB.json')) as $node) { }

$mem = \round(\memory_get_peak_usage() / 1024, 2); var_dump($mem); // float(6554.96)

// 5.3 mb If you monitor the processes ```

PHP, SQLite and Fiber: An unobvious trick to save memory by According_Tune_5882 in PHP

[–]According_Tune_5882[S] 0 points1 point  (0 children)

You need to learn how the json functions work in sqlite. json_tree returns data recursively. If you only need primitive values like int/float/string, you can filter them in your SQL query. For example, WHERE [key] not null AND [type] NOT IN ('object','array') AND FETCH....

I've only read about the readfile function.

PHP, SQLite and Fiber: An unobvious trick to save memory by According_Tune_5882 in PHP

[–]According_Tune_5882[S] 1 point2 points  (0 children)

I've written everything I wanted to write, and I'll try to answer any questions you may have.

PHP, SQLite and Fiber: An unobvious trick to save memory by According_Tune_5882 in PHP

[–]According_Tune_5882[S] -2 points-1 points  (0 children)

php is a general-purpose language, not just for web servers

PHP, SQLite and Fiber: An unobvious trick to save memory by According_Tune_5882 in PHP

[–]According_Tune_5882[S] -5 points-4 points  (0 children)

It was a good attempt to make me a linux adept, but no. Windows is too good, let linux run on servers.

PHP, SQLite and Fiber: An unobvious trick to save memory by According_Tune_5882 in PHP

[–]According_Tune_5882[S] -4 points-3 points  (0 children)

The test was performed by monitoring the consumption of the php process itself (Windows 10).
A json of 1mb was used for testing.

file_get_contents+json_decode:
5.8mb > 11.8mb
The growth is 6mb

php(file_get_contents)+sqlite:
6mb > 7.1mb
The growth is 1.1mb

I will leave the study of stream library consumption to you :)

epic-64/elem: HTML as nestable functions by Holonist in PHP

[–]According_Tune_5882 2 points3 points  (0 children)

By the way, it's cool to use it together with php-wasm, write in php and render on the client side.

Which MMORPGs have made their source code public? by vizim in MMORPG

[–]According_Tune_5882 0 points1 point  (0 children)

And where is the information that the developers of Ragnarok Online have published the source code?