第二种情况: IF NOT condition THEN //Code goes here. END IF 和 IF condition THEN //No code goes here. ELSE //Code goes here. END IF 对于上一" name="description" />

PB代码优化(2)

发表于:2007-06-07来源:作者:点击数: 标签:
MI LY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> 第二种情况: IF NOT condition THEN //Code goes here. END IF 和 IF condition THEN //No code goes here. ELSE //Code goes here. END IF 对于上一
  MILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第二种情况:

IF NOT condition THEN

      //Code goes here.

END IF

IF condition THEN

      //No code goes here.

ELSE

      //Code goes here.

END IF

 

对于上一种方式,条件表达式返回false并且再进行一个运算,才执行下面的代码。这样相对于下面一种书写方式可能多执行了一个运算。如果大家有什么疑问,您不妨测试一下下面这个例子:

 

//小测试:其中的判断条件只是为了表示一下,实际情况可能更复杂。

 

long i                   //计数器

long ll_start          //执行开始时间

long ll_used1       //方式一耗时

long ll_used2       //方式二耗时

 

//方式一

ll_start = Cpu()

for i = 1 to 900000

      if not (1 > 1) Then

             i = i

      end if

next        

ll_used1 = Cpu() - ll_start


原文转自:http://www.ltesting.net