PHPisset () and empty () function execution time comparison _ PHP Tutorial

Source: Internet
Author: User
PHPisset () and empty () function execution time comparison. The article uses charts to tell you how to compare the execution time of PHPisset () and empty () functions and the performance is good or bad. if you need them, please take a look at them in detail. Performance testing uses Benchmark _ the article uses charts to tell you how to compare the execution time of PHP isset () and empty () functions and the performance is good or bad, if you have any need, please take a look at it in detail. Performance testing uses the Benchmark_Iterate tool for debugging, focusing on the isset () and empty () function execution time.

, Test environment
Operating system: Window XP
PHP Version: PHP Version 5.2.11
Apache version: Apache 2.0 Handler

II. test method
Use Benchmark_Iterate to test isset () and empty 50 times and generate a chart if the variable exists and does not exist

3. isset () and empty () determine if the variable does not exist.
1. test code

The code is as follows:

Require_once "Benchmark/Iterate. php ";
$ Tenant = new Benchmark_Iterate;
Function check1 ($ var ){
Isset ($ var );
}
Function check2 ($ var ){
! Empty ($ var );
}
$ Activities-> run (50, "check1", $ var );
// $ Response-> run (50, "check2", $ var );
$ Result = $ response-> get ();


$ Var variable is not initialized to determine whether the variable does not exist. the execution of the two functions can be as follows:

2. isset () determines if the variable does not exist.

Illustration: when isset () judges that a variable does not exist, the average execution time is between 0.0010 and 0.0011 seconds.
3. empty () determines if the variable does not exist.


Illustration: empty () determines that the variable does not exist. The average execution time is between 0.0010 and 0.0011 seconds.
4. isset () and empty () determine the existence of variables

, Test code

The code is as follows:

Require_once "Benchmark/Iterate. php ";
$ Tenant = new Benchmark_Iterate;

Function check1 ($ var ){
Isset ($ var );
}
Function check2 ($ var ){
! Empty ($ var );
}
$ Var = true;
$ Activities-> run (50, "check1", $ var );
// $ Response-> run (50, "check2", $ var );
$ Result = $ response-> get ();

Initialize the $ var variable to true to determine whether the variable exists. the execution performance of the two functions is as follows:

2. isset () determines the existence of a variable

Illustration: isset () determines the existence of a variable. The average execution time is between 0.0010 and 0.0011 seconds. 3. empty () determines the existence of a variable. Illustration: isset () judging the existence of variables, the average execution time is between 0.0010-0.0011 seconds. Considering the above test performance, we can see that the execution time of isset () and empty () functions is basically the same, the average execution time of the two functions is between 0.0010-0.0011 seconds. of course, this is related to the specific environment. from the current test environment, the performance of the two functions is the same.

The execution time of the isset () and empty () functions is compared, and the performance is good or bad. if you need it, you can take a look at it in detail. Benchmark _...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.