, 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: |
Copy code |
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 performance of the two functions is shown in the figure below.
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: |
Copy code |
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 () is used to determine 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.
Based on the 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.