183 文字
1 分
PEARのMailにて、persist有効時のパフォーマンス
PEARのMailを使って、SMTP接続をしてメール送信をする際、
persistを使ったときと使わなかったときのパフォーマンスを測定しました。
条件
100通メール送信
MTAはqmail
結果
persist利用時: 5.12351703644 sec
persist非利用時: 6.3600769043 sec
結果
persistを使うと1.24134981089459 倍速いです。
以下、テストコード
<?php/** Created on 2007/01/15** To change the template for this generated file go to* Window - Preferences - PHPeclipse - PHP - Code Templates*/include('Mail.php');require_once('Benchmark/Timer.php');
$timer = new Benchmark_Timer();
$headers['To'] = $recipients;$headers['Subject'] = 'subject';
$body = 'Test message';
// SMTPサーバ$mail_options = array( 'host' => 'localhost', 'port' => 25, 'auth' => false, 'persist' => false);
// Create the mail object using the Mail::factory method$mail_object = &Mail::factory('smtp',$mail_options); // SMTP送信準備
$timer->start();for($i=0;$i < 100;$i++){ $mail_object->send($recipients, $headers, $body.':'.$i);}$timer->stop();$timer->display();print_r($timer->getProfiling()); PEARのMailにて、persist有効時のパフォーマンス
https://blog.teraren.com/posts/pearのmailにてpersist有効時のパフォーマンス/