As a result of recent work in the area of memcached
PHP and Perl were used in the performance test to memcached the performance difference between PHP and Perl for memcached operations around 40~50%
The following is a test script that does the same thing. Repeat 512,000 times with 1k of data., insert a total of memcached 500M of data
PHP Action Script
Ini_set ("Memcache.hash_function", "CRC32");
$memcache =newmemcache;
$memcache->addserver (localhost,30001);
$memcache->flush ();
for ($i =0; $i <512000; $i + +) {
$memcache->set ($i,
"1k of fill Data", 0,1000);
}
?>
And then the Perl script
#!/usr/bin/perl
Use cache::memcached ();
$memcache =newcache::memcached{servers=>["localhost:30001"};
$memcache->flush_all ();
for ($i =0; $i <512000; $i + +) {
$memcache->set ($i,
"Total 1k of fill data");
}
$memcache->disconnect_all ();
In terms of the number of lines of code. They're almost unanimous.
But the test results are very different.
We timed the execution using time under Linux
3 execution results are as follows
[Root@lenovo5 ~]# time./test1k.pl
Real 1m2.265s
User 0m36.427s
SYS 0m17.114s
[Root@lenovo5 ~]# time./test1k.pl
Real 1m2.814s
User 0m36.380s
SYS 0m17.463s
[Root@lenovo5 ~]# time./test1k.pl
Real 1m13.684s
User 0m44.603s
SYS 0m18.366s
[Root@lenovo5 ~]# time PHP./test1k.php
Real 0m38.055s
User 0m11.768s
SYS 0m13.891s
[Root@lenovo5 ~]# time PHP./test1k.php
Real 0m38.892s
User 0m12.416s
SYS 0m14.044s
[Root@lenovo5 ~]# time PHP./test1k.php
Real 0m38.955s
User 0m12.430s
SYS 0m13.088s
The difference is obvious. Perl execution takes about 1 minutes and PHP only takes 40 seconds, or PHP executes about 40% faster than Perl.
After analysis there are several factors that may
1. Perl's string processing is slow. We see that the length parameter is not required in the Perl version of the set. So each insertion may require a set function to determine the length of the string passed in. This may be slower. But then we found that the PHP set has length parameters. But this parameter is not mandatory. For example, I wrote 100. 0, the actual string has 1200. The result will be a string with a length of 1200 inserted without truncation. So that's not a very good place to stand.
The 2.perl extension is different from the PHP extension implementation. PHP's Memcache client is PECL, which is the C extension, and Perl's extended implementation is probably Perl. So there will be performance differences.
http://www.bkjia.com/PHPjc/508338.html www.bkjia.com true http://www.bkjia.com/PHPjc/508338.html techarticle as a result of the recent work on memcached, PHP and Perl were used in the performance test to memcached the performance difference between PHP and Perl for memcached operations in the 40~50% ...