Skip to content

Instantly share code, notes, and snippets.

@dshafik
Last active September 12, 2016 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dshafik/2d4b2b7fe87486c2314f to your computer and use it in GitHub Desktop.
Save dshafik/2d4b2b7fe87486c2314f to your computer and use it in GitHub Desktop.
PHP Performance I: Everything You Need to Know About OpCode Caches, examples
[zendopcache]
zend_extension=/full/path/to/opcache.so ; May be added by pecl
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1
[apcu]
extension=apcu.so ; May be added by pecl
apc.serializer=php ; See bug report for more info: http://ey.io/1aJhcOY
[apc]
extension=apc.so ; May be added by pecl
apc.enabled=1
"repositories": [
{
"type": "vcs",
"url": "http://github.com/engineyard/ey-php-performance-tools"
}
],
"require": {
"php": ">=5.3.3",
"engineyard/php-performance-tools": "dev-master"
}
<?php
return [
/* URLs to cache */
'urls' => [
'http://ephernote.com/',
'http://ephernote.com/user/login',
'http://ephernote.com/user/register',
'http://ephernote.com/privary', // Note: this is a typo
],
/* How many concurrent HTTP requests to make (requires the pecl_http extension) */
'threads' => 3
];
=== Cache Primer ===
Attempting to cache 4 URLs:
Running in parallel with 3 concurrent requests
...!
Cached 3 URLs in 0.6162059307098 seconds
Encountered 1 errors
=== Cache Primer ===
Attempting to cache 104 URLs:
Running in parallel with 10 concurrent requests
............................................................................!...........................
Cached 103 URLs in 4.6162059307098 seconds
Encountered 1 errors
<?php
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
return [
/* Authentication */
'auth' => [
'enabled' => true,
'username' => 'admin',
'password' => 'changeme',
],
/* Paths to cache (recursively) */
'paths' => [
__DIR__ .DS. '..' .DS. '..' .DS. '..' .DS. 'config',
__DIR__ .DS. '..' .DS. '..' .DS. '..' .DS. 'module',
__DIR__ .DS. '..' .DS. '..' .DS. '..' .DS. 'vendor',
__DIR__ .DS. '..' .DS. '..' .DS. '..' .DS. 'public',
]
];
<?php
// public/admin/apc-cache-primer.php
require '../../vendor/engineyard/php-performance-tools/apc-primer/apc-primer.php';
<?php
class Greeting {
public function sayHello($to)
{
echo "Hello $to";
}
}
$greeter = new Greeting();
$greeter->sayHello("World");
?>
extension=vld.so
Class Greeting:
Function sayhello:
filename: ./Greeting.php
function name: sayHello
compiled vars: !0 = $to
line # * op fetch ext return operands
------------------------------------------------------------------------
Class Greeting:
Function sayhello:
number of ops: 8
compiled vars: !0 = $to
line # * op fetch ext return operands
----------------------------------------------------------------------------
3 0 > EXT_NOP
1 RECV !0
5 2 EXT_STMT
3 ADD_STRING ~0 'Hello+'
4 ADD_VAR ~0 ~0, !0
5 ECHO ~0
6 6 EXT_STMT
7 > RETURN null
function name: (null)
number of ops: 17
compiled vars: !0 = $greeter
line # * op fetch ext return operands
----------------------------------------------------------------------------
2 0 > EXT_STMT
1 NOP
9 2 EXT_STMT
3 FETCH_CLASS 4 :1 'Greeting'
4 EXT_FCALL_BEGIN
5 NEW $2 :1
6 DO_FCALL_BY_NAME 0
7 EXT_FCALL_END
8 ASSIGN !0, $2
10 9 EXT_STMT
10 INIT_METHOD_CALL !0, 'sayHello'
11 EXT_FCALL_BEGIN
12 SEND_VAL 'World'
13 DO_FCALL_BY_NAME 1
14 EXT_FCALL_END
12 15 EXT_STMT
16 > RETURN 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment