Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perf gain in masking #226

Closed
cboden opened this issue Aug 21, 2014 · 1 comment
Closed

Perf gain in masking #226

cboden opened this issue Aug 21, 2014 · 1 comment

Comments

@cboden
Copy link
Member

cboden commented Aug 21, 2014

From @rdlowrey via IRC:

Using str_pad instead of looping over the payload to mask/de-mask should yield a performance gain:

$payload = $payload ^ str_pad('', $length, $mask, STR_PAD_RIGHT);
cboden added a commit to ratchetphp/RFC6455 that referenced this issue May 31, 2015
@Xaraknid
Copy link

Xaraknid commented Jan 7, 2016

You should try str_repeat I made some benchmark spec with various method and it's happen to be the fastest. The samplesize I use is 1000000.

$effectiveMask = str_repeat($this->mask , ($samplesize/4)+1 );
$over=$samplesize-strlen($effectiveMask);
$effectiveMask=substr($effectiveMask,0,$samplesize);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants