Работа с массивом на PHP
Проведено исследования на сервере скорости обработки большого массива строк (166385 строк) и способ хранения массива в виде текстового фала (подобно csv с разделителем строк "переносом строки" и разделителем полей "табуляцией"), в виде сериализации массива. Оба способа при записи на диск подвергаются сжатию функцией gzencode(), таким образом занимат примерно в 5 раз меньше памяти (2 Мб вместо 10Мб). Нужно доработать эксперимент проверкой еще одного способа указанного здесь http://qaru.site/questions/123310/how-do-i-store-an-array-in-a-file-to-access-as-an-array-later-with-php (ищите на странице фразу "Еще один быстрый способ"), только попробуйте запаковать массив в виде : https://www.php.net/manual/ru/phar.using.intro.php и потом подключить файл к основному скрипту.
Вообщем Ваша задача сделать пример выгруззки любого массива в Phar-архив и затем подключить его. По идее такой способ хранения будет занимать места не больше чем gzip-архив, при этом подключаться гораздо быстрее. Поскольку сейчас узким местом является десериализации массива либо разбивка строк либо разбивка строк при помощи explode. И проверить, будет ли способ через подключение Phar-архива работать быстрее, чем десериализация. Поскольку еще пробовали eval http://qaru.site/questions/123310/how-do-i-store-an-array-in-a-file-to-access-as-an-array-later-with-php как описано здесь, но более быстрых результатов это почему-то не дало.
Все время в єксперименте обозначено в миллисекундах: с*10-3.
Результату єксперимента:
Разрешено ОЗУ: 128M
Еxplode
Время создания массива csv: 258.46с*10-3
Всего: 166385 строк
Пик ОЗУ: 86.75Мб
Сериализация
Время сериализации массива: 65.21с*10-3
Время записи ser: 70.69с*10-3
Время считывания ser: 5.34с*10-3
Время десериализации массива: 88.88с*10-3
Всего: 166385 строк
Разрешено ОЗУ: 128M
Пик ОЗУ: 125.5Мб
-
1482 28 0 Обращайтесь, сделаю
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Current freelance projects in the category PHP
Multifunctional HTML template for a betting website and parsing match API (
25 USD
I have a Sportsbook API, I need to download a template for an online betting website from the internet and integrate match parsing and a payment system into it) the task is very simple, write who can do it right away) essentially, I need a basic website for testing with a… PHP, Python ∙ 2 hours 11 minutes back ∙ 11 proposals |
Resolve the loading issue on the PrestaShop website hostingThe website requires more and more resources each month. The host's response: During the server check, increased load from the MySQL database server was recorded. At times of the 500 error, the MySQL process uses a significant portion of CPU resources, which can lead to unstable… PHP, Databases & SQL ∙ 3 hours 7 minutes back ∙ 16 proposals |
Integration needed: KeyCRM → Cash Register KashalotIt is necessary to set up integration between KeyCRM and the Cash Register Kahalot. When placing an order in KeyCRM, the data must be automatically transmitted to Kahalot: • order information • products, nomenclature • prices • quantity More details in private. Content Management Systems, PHP ∙ 4 hours 27 minutes back ∙ 13 proposals |
Development of a single project based on the refinement and integration of 4 scriptsHello. I need to combine 4 scripts from different authors into a single environment. The composition includes a forum, a video portal, an article portal, and a classifieds board. I will provide the scripts. Detailed specifications are in the attached files. Please think about… PHP, Web Programming ∙ 1 day 10 hours back ∙ 28 proposals |
A WordPress site using the Kadence theme and Kadence Blocks.
225 USD
We need to create a website on WordPress using the Kadence theme and Kadence Blocks. There will be no online store (although it may be added in the future). We need a homepage and several internal pages. The graphics are already prepared, the layout structure is mostly defined,… Content Management Systems, PHP ∙ 1 day 14 hours back ∙ 37 proposals |