Skip to content

Instantly share code, notes, and snippets.

@dstogov
Last active May 14, 2021 06:19
Show Gist options
  • Save dstogov/d62cfc8cd62b70516e00957c24aa1881 to your computer and use it in GitHub Desktop.
Save dstogov/d62cfc8cd62b70516e00957c24aa1881 to your computer and use it in GitHub Desktop.
<?php
define("BAILOUT",16);
define("MAX_ITERATIONS",1000);
class Mandelbrot
{
function __construct()
{
$d1 = microtime(1);
for ($y = -39; $y < 39; $y++) {
for ($x = -39; $x < 39; $x++) {
if ($this->iterate($x/40.0,$y/40.0) == 0)
echo("*");
else
echo(" ");
}
echo("\n");
}
$d2 = microtime(1);
$diff = $d2 - $d1;
printf("\nPHP Elapsed %0.3f\n", $diff);
}
function iterate($x,$y)
{
$cr = $y-0.5;
$ci = $x;
$zr = 0.0;
$zi = 0.0;
$i = 0;
while (true) {
$i++;
$temp = $zr * $zi;
$zr2 = $zr * $zr;
$zi2 = $zi * $zi;
$zr = $zr2 - $zi2 + $cr;
$zi = $temp + $temp + $ci;
if ($zi2 + $zr2 > BAILOUT)
return $i;
if ($i > MAX_ITERATIONS)
return 0;
}
}
}
ob_start();
$m = new Mandelbrot();
ob_end_flush();
ob_start();
$m = new Mandelbrot();
ob_end_flush();
date.timezone=GMT
max_execution_time=600
memory_limit=1G
user_ini.filename=
realpath_cache_size=2M
cgi.check_shebang_line=0
;error_reporting=E_ALL | E_STRICT
;display_errors=1
;log_errors=1
;report_zend_debug=1
error_reporting=0
display_errors=0
log_errors=0
zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
;opcache.protect_memory=1
opcache.jit_buffer_size=32M
opcache.fast_shutdown=1
opcache.validate_timestamps=1
;opcache.revalidate_path=1
opcache.revalidate_freq=60
opcache.use_cwd=1
opcache.max_accelerated_files=100000
opcache.max_wasted_percentage=5
opcache.memory_consumption=128
opcache.consistency_checks=0
opcache.huge_code_pages=1
;opcache.enable_file_override=1
zend.assertions=-1
;opcache.file_cache=/tmp/opcache
;opcache.file_cache_only=1
;opcache.file_cache_consistency_checks=0
;opcache.preload=/home/dmitry/php/usr/php-trunk/etc/preload.php
;opcache.jit=1204
;opcache.jit_hot_loop=1
;opcache.jit_hot_func=1
;opcache.jit_hot_return=1
;opcache.jit_hot_side_exit=1
;opcache.jit_blacklist_root_trace=16
;opcache.jit_blacklist_side_trace=8
;opcache.jit_max_loops_unroll=1
;opcache.jit_max_recursive_calls=2
;opcache.jit_max_recursive_returns=2
;opcache.jit_max_polymorphic_calls=2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment