I have run some testcases with interesting results.
First, the code... ********************************* class test method main(s=String[]) static test() method test() notdefined() defined_double() method notdefined() time1 = System.currentTimeMillis() loop i=0 to 100 by 0.01 nop end time2 = System.currentTimeMillis() time3 = time2-time1 say 'Variable not defined' say 'Start: 'time1 say 'End: 'time2 say 'diff: 'time3 method defined_double() i = double 0 time1 = System.currentTimeMillis() loop i=0 to 100 by 0.01 nop end time2 = System.currentTimeMillis() time3 = time2-time1 say 'Variable defined as double' say 'Start: 'time1 say 'End: 'time2 say 'diff: 'time3 ****************** then, the output... Variable not defined Start: 936859382131 End: 936859382381 diff: 0 Variable defined as double Start: 936859382611 End: 936859402290 diff: 20000 There are 2 interesting things. 1.) The conversion from long to Rexx causes loss of information. If you subtract time2 from time1 in the first case you should get 250ms - the output writes 0. 2.) Defining index-variables as double() is MUCH slower than Rexx or int (20x). -- Servus, Andreas ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to [hidden email] with the following message in the body of the note unsubscribe ibm-netrexx <e-mail address> |
Explanations: > 1.) The conversion from long to Rexx causes loss of information. If you > subtract time2 from time1 in the first case you should get 250ms - the > output writes 0. You can set Rexx precision as desired, for example: numeric digits 200 which should be plenty :-) The default precision is 9 digits. > 2.) Defining index-variables as double() is MUCH slower than Rexx or int > (20x). The code you wrote makes the index variable double, but the counting is done in decimal .. so there's a conversion to double each time round the loop. To have it run in binary (i.e., the additions be carried out in binary) try making the method binary (that is, add the keyword BINARY to the method instruction). You may find that the number of times round the loop is unpredictable, as 0.01 cannot be represented exactly by a double. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Mike Cowlishaw, IBM Fellow mailto:[hidden email] -- http://www2.hursley.ibm.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to [hidden email] with the following message in the body of the note unsubscribe ibm-netrexx <e-mail address> |
Free forum by Nabble | Edit this page |