Talk:Rosetta Code/(Strictly) equal in Rexx: Difference between revisions

From Rosetta Code
Content added Content deleted
(fighting the edit)
m (Got it hopefully right now!)
Line 3: Line 3:
strictly equal a==b tests the values byte for byte, so '1'==' 01e0 ' -> 0 (false)
strictly equal a==b tests the values byte for byte, so '1'==' 01e0 ' -> 0 (false)
equal a=b tests the values more generously
equal a=b tests the values more generously
it strips leading and trailing blanks and, if both values are numbers compares them arithmetically (observing the Numeric Digits setting)
it strips leading and trailing blanks and, if both values are
numbers compares them arithmetically (observing the Numeric Digits setting)
so '1'==' 01e0 ' -> 1 (true)
so '1'=' 01e0 ' -> 1 (true)
I performed a little performance test on TSO.
I performed a little performance test on TSO.
</pre>
</pre>

Revision as of 07:31, 5 July 2012

Rexx has two comparison operators (for testing equality)
strictly equal a==b tests the values byte for byte, so '1'==' 01e0 ' -> 0 (false)
         equal a=b tests the values more generously 
                       it strips leading and trailing blanks and, if both values are
           numbers compares them arithmetically (observing the Numeric Digits setting)
                                                    so '1'=' 01e0 ' -> 1 (true)
I performed a little performance test on TSO.

<lang rexx> /* REXX ***************************************************************

  • Compare the performance of equal vs. strictly equal
  • 05.07.2012 Walter Pachl
                                                                                                                                            • /

Parse Version v Say 'eqtest on Rexx Version' v Say ' Hits Misses test = Test == == improvement' Call random 1,10,12345 /* set seed */ Do i=1 To 100000

 x.i=random()                                                         
 End                                                                  

Do rep=1 To 5

 cnt.=0                                                               
 Call time 'R'                                                        
 Do i=1 To 100000                                                     
   If x.i=999 Then cnt.1=cnt.1+1                                      
               Else cnt.0=cnt.0+1                                     
   End                                                                
 cnt.=0                                                               
 te=time('R')                                                         
 Do i=1 To 100000                                                     
   If x.i==999 Then cnt.1=cnt.1+1                                     
               Else cnt.0=cnt.0+1                                     
   End                                                                
 tse=time('E')                                                        
 Say right(cnt.0,5) right(cnt.1,5),                                   
     format(te,2,8) format(tse,2,8) format((100*(te-tse)/te),3,8)'%'  
 End   

</lang>

The results:
Interpreter:
eqtest on Rexx Version REXX370 3.48 01 May 1992
 Hits Misses test =      Test ==      == improvement
99894   106  0.15227900  0.14603100   4.10299516%
99894   106  0.14801500  0.14583200   1.47485052%
99894   106  0.15465700  0.15261200   1.32228092%
99894   106  0.15660000  0.14936200   4.62196679%
99894   106  0.15060800  0.17170400 -14.00722410%

Compiled Rexx:
eqtest on Rexx Version REXXC370 3.48 23 Dec 1999
 Hits Misses test =      Test ==      == improvement
99894   106  0.01011300  0.01730900 -71.15593790%
99894   106  0.00983700  0.01328100 -35.01067400%
99894   106  0.00973800  0.01293300 -32.80961180%
99894   106  0.00984500  0.01306300 -32.68664300%
99894   106  0.01005300  0.01423700 -41.61941710%

As I was part of the Compiler Development Team in the former IBM Lab Vienna
I am rather proud of my friends' achievement!

You are invited to test this on your platform with your Rexx!

--Walterpachl 07:28, 5 July 2012 (UTC)