简体   繁体   English

HipHop PHP-字符串concat问题

[英]HipHop PHP - Issues with string concat

I'm having serious issues with string concatenation in HipHop->C++ compiled PHP scripts. 在HipHop-> C ++编译的PHP脚本中,字符串连接存在严重问题。

My scripts rely heavily on concatenating strings, it performs in 0.6 seconds with PHP and 60 seconds compiled with HipHop. 我的脚本严重依赖于连接字符串,使用PHP的执行时间为0.6秒,使用HipHop编译的执行时间为60秒。 That's almost a 10,000% difference! 这几乎相差10,000%!

Appears to be a problem with dynamic memory allocation, according to this article : 根据本文 ,似乎是动态内存分配存在问题:

They prove our suspicions. 他们证明了我们的怀疑。 Source code compilation brings major side effect known from other compiled languages ​​such as C, C++ or C#: slow string operations, and the need for StringBuilder functionality!. 源代码编译带来了其他编译​​语言如C,C ++或C#带来的主要副作用:缓慢的字符串操作以及对StringBuilder功能的需求!

HipHop compiled scripts are considerably faster in all other areas, giving a speed and memory improvement of around 50%, which is something important to my project. HipHop编译脚本在所有其他方面都快得多,速度和内存提高了约50%,这对我的项目很重要。

My question is: what kind of trick could I pull (in PHP code) to force the HipHop compiled PHP scripts to pre-allocate the memory needed, or whatever, to stop this obscure dynamic memory allocation which causes intense slowdown. 我的问题是:我可以采用哪种技巧(在PHP代码中)来强制HipHop编译的PHP脚本预先分配所需的内存,或者采取任何措施阻止这种晦涩的动态内存分配,从而导致严重的速度下降。 Or is there another clever little way of concatenating strings, or some kind of string-builder implementation? 还是还有另一种巧妙的串联字符串的小方法,或者某种字符串生成器实现?

HPHPc has been deprecated. HPHPc已被弃用。 Try using HHVM https://github.com/facebook/hiphop-php 尝试使用HHVM https://github.com/facebook/hiphop-php

Could you provide an example of how you're actually performing the concatenation, as seen in this post, there could be some simple improvements that could be made. 如本文中所见,您能否提供一个示例说明如何实际执行串联,所以可以进行一些简单的改进。

Optimizing PHP string concatenation 优化PHP字符串连接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM