============================================================================= 【Problem】 http://php80ub20.solar.lan/phpkobo/website/public_html/mod/ETOBF/v1.48/demo/demo.html のデモが遅い。 ----------------------------------------------------------------------------- HObfusをキャシュしてみたが、変わらない。 ETObfの実行をDomContentLoadedの10秒後にしてみたが、やはり変わらない。 つまり、時間がかかっているのは、etobfのロード時の実行である。 ///////////////////////////////////////////////////////////////////////////// etobfのロード時の中でも「CJsObjShield_shift」で時間がかかっている。 CJsObjShield_shiftがOnの場合は、Offの場合の、 スクリプトのロード&実行時間が100倍になる。 ================== CJsObjShield_shift ==>Off ------------------ 4.7 7.9 7.9 5.8 9.7 5.0 7.0 5.6 6.8 7.3 ------------------ Ave 6.7ms ================== ================== CJsObjShield_shift ==>On ------------------ 590 609 599 617 622 605 598 605 603 606 ------------------ Ave 605.4ms ================== ///////////////////////////////////////////////////////////////////////////// 「CJsObjShield_shift」の中でも以下の部分で時間がかかっている。 ----------------------------------------------------------------------------- console.time("shifting"); //@@ iterate through each character of txt for($_idx=$_zero;$_idx<$_txt["length"];$_idx++){ //@@ n = asc( txt[idx] ) $_n=$_txt["charCodeAt"]($_idx); //@@--------------------------------------------------------------------------------------- //@@ result += chr( n<32 or 126map[ch]) は使っておらず、("replace-and-callback") forループでmapをおこなっている。("replace-in-loop") ----------------------------------------------------------------------------- 【Solution】 (1) ETObfの「CJsObjShield_shift」ではshiftingを省く。 (2) HTObfusの「CJsObjShield_shift」ではshiftingには、mappingに書き換える。 (3) HTObfusでの、HTMLのCaesar-Cipherはすでにmap型なので変更の必要はない。 "replace-and-callback"方式で、"replace-in-loop"ではないが、 両者に大きなスピードの違いはない。 詳細: my-projects/etobf/ETOBF-148/public_html/research/efficent-Caesar-Cipher/task.php =============================================================================