我有一个基本函数,它迭代x,y坐标数组以创建一系列PNG图像(下图)。我正在努力优化此脚本的性能,但是从1 CPU / 2GB RAM升级我的服务器 - > 16个CPU(相同的时钟速度)/ 32GB RAM并没有对执行时间产生影响。
我通过多个进程监控了内存使用情况,而且它似乎从未使用超过700mb RAM。有什么办法可以修改这个脚本以在我的服务器上使用更多资源吗?
function annotateFrames($text, $x, $y) {
for ($i = 0; $i <= 100; $i++) {
$image = new Imagick();
$draw = new ImagickDraw();
$pixel = new ImagickPixel('yellow');
$image->newImage(1920, 1080, $pixel);
$draw->setFillColor('blue');
$image->annotateImage($draw, $x[$i], $y[$i], 0, $text);
$image->setImageFormat('png');
$image->setOption('png:bit-depth', '16');
$image->setOption('png:color-type', 6);
$image->writeImage('path/'.$i.'.png');
}
}