EC-CUBE / ec-cube2

EC-CUBE official repository version 2
https://www.ec-cube.net
Other
86 stars 97 forks source link

script_escape パフォーマンス改善 #955

Closed seasoftjapan closed 2 months ago

seasoftjapan commented 2 months ago

ざっくり十数倍速くなったようです。

(参考) 検証コードと結果

require_once 'modifier.script_escape.php';
$arr = [];
for ($i = 1; $i <= 1000000; $i ++) {
    $arr[] = uniqid();
}
$start = microtime(true);
foreach ($arr as $str) {
    smarty_modifier_script_escape($str);
}
echo microtime(true) - $start . PHP_EOL;
$ git restore --source=ofc/master data/smarty_extends/modifier.script_escape.php
$ php data/smarty_extends/modifier.script_escape_test.php
6.0050699710846
$ git restore --source=seasoft-script_escape data/smarty_extends/modifier.script_escape.php
$ php data/smarty_extends/modifier.script_escape_test.php
0.41585803031921
codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 55.69%. Comparing base (4ba247b) to head (0dded83).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #955 +/- ## ======================================= Coverage 55.69% 55.69% ======================================= Files 75 75 Lines 8905 8905 ======================================= Hits 4960 4960 Misses 3945 3945 ``` | [Flag](https://app.codecov.io/gh/EC-CUBE/ec-cube2/pull/955/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=EC-CUBE) | Coverage Δ | | |---|---|---| | [tests](https://app.codecov.io/gh/EC-CUBE/ec-cube2/pull/955/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=EC-CUBE) | `55.69% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=EC-CUBE#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.