forked from PHPMailer/PHPMailer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using psr-16-simple-cache on MIMECache $ php composer require psr/simple-cache $ php benchmark_reduce_mime_encoding.phps ... Size Method1 Method2 Method3 Method4 1.8kb 0.0645 0.1205 0.0573 0.1064 5.7kb 0.0814 0.1740 0.0605 0.1509 50kb 0.0872 0.1698 0.0622 0.1473 100kb 0.1030 0.1839 0.0678 0.1496 200kb 0.1302 0.2208 0.0677 0.1567 500kb 0.2261 0.3194 0.0878 0.1730
- Loading branch information
Showing
4 changed files
with
98 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ require '../vendor/autoload.php'; | |
// $ curl https://sample-videos.com/img/Sample-jpg-image-200kb.jpg > /tmp/200kb.jpg | ||
// $ curl https://sample-videos.com/img/Sample-jpg-image-100kb.jpg > /tmp/100kb.jpg | ||
// $ curl https://sample-videos.com/img/Sample-jpg-image-50kb.jpg > /tmp/50kb.jpg | ||
// | ||
$image_files = array( | ||
'1.8kb' => 'phpmailer_mini.png', | ||
'5.7kb' => 'images/phpmailer.png', | ||
|
@@ -102,7 +101,7 @@ echo "Sending $receiver_count mails with only one PHPMailer instance: \n"; | |
$mail->addReplyTo('[email protected]', 'First Last'); | ||
|
||
foreach ($receiver_list as $receiver) { | ||
$mail->clearAddresses(); | ||
$mail->clearAddresses(); | ||
$mail->addAddress($receiver); | ||
$mail->Subject = 'Hi '.$receiver.'!'; | ||
$mail->msgHTML(str_replace( '<h1>This is a test of PHPMailer.</h1>', '<h1>Hi '.$receiver.'</h1>', file_get_contents('contents.html')), __DIR__); | ||
|
@@ -127,6 +126,46 @@ echo "Sending $receiver_count mails with only one PHPMailer instance: \n"; | |
} | ||
} | ||
|
||
class MyCacheHelper implements Psr\SimpleCache\CacheInterface { | ||
protected $cacheStore = []; | ||
public function get($key, $default = null) { | ||
if (array_key_exists($key, $this->cacheStore)) { | ||
return $this->cacheStore[$key]; | ||
} | ||
|
||
return $default; | ||
} | ||
|
||
public function set($key, $value, $ttl = null) { | ||
$this->cacheStore[$key] = $value; | ||
} | ||
|
||
public function delete($key) { | ||
usset($this->cacheStore[$key]); | ||
} | ||
|
||
public function clear() { | ||
usset($this->cacheStore); | ||
$this->cacheStore = []; | ||
} | ||
|
||
public function has($key) { | ||
return array_key_exists($key, $this->cacheStore); | ||
} | ||
|
||
public function getMultiple($keys, $default = null) { | ||
|
||
} | ||
|
||
public function setMultiple($values, $ttl = null) { | ||
|
||
} | ||
|
||
public function deleteMultiple($keys) { | ||
|
||
} | ||
} | ||
|
||
echo "Sending $receiver_count mails with creating a new PHPMailer instance and MIMECache: \n"; | ||
{ | ||
foreach ($image_files as $filesize => $image_file) { | ||
|
@@ -135,7 +174,7 @@ echo "Sending $receiver_count mails with creating a new PHPMailer instance and M | |
for ($i=1; $i<=$test_count_per_run ; ++$i) { | ||
//echo "\t\tRun $i: "; | ||
$start = microtime(true); | ||
$cacheLookupTable = []; | ||
$cacheLookupTable = new MyCacheHelper; | ||
foreach ($receiver_list as $receiver) { | ||
$mail = new PHPMailer; | ||
$mail->isSMTP(); | ||
|
@@ -182,7 +221,7 @@ echo "Sending $receiver_count mails with only one PHPMailer instance and MIMECac | |
for ($i=1; $i<=$test_count_per_run ; ++$i) { | ||
//echo "\t\tRun $i: "; | ||
$start = microtime(true); | ||
$cacheLookupTable = []; | ||
$cacheLookupTable = new MyCacheHelper; | ||
|
||
$mail = new PHPMailer; | ||
$mail->isSMTP(); | ||
|
@@ -196,7 +235,7 @@ echo "Sending $receiver_count mails with only one PHPMailer instance and MIMECac | |
$mail->addReplyTo('[email protected]', 'First Last'); | ||
|
||
foreach ($receiver_list as $receiver) { | ||
$mail->clearAddresses(); | ||
$mail->clearAddresses(); | ||
$mail->addAddress($receiver); | ||
$mail->Subject = 'Hi '.$receiver.'!'; | ||
$mail->msgHTML(str_replace( '<h1>This is a test of PHPMailer.</h1>', '<h1>Hi '.$receiver.'</h1>', file_get_contents('contents.html')), __DIR__); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters