REBOL3 tracker
  0.9.12 beta
Ticket #0001638 User: anonymous

Project:

Previous Next
rss
TypeIssue Statusdismissed Date26-Jul-2010 12:02
Versionalpha 99 CategoryNative Submitted byLadislav
PlatformAll Severitynot a bug Prioritynormal

Summary Peculiar timing differences and refinement handling of the SET function
Description Using the FUNCT function I found it useful to use a set [a: b:] [1 2] type of expression instead of the "more conventional" set [a b] [1 2].

I was surprised, that the timing of SET depends on the word type. See my results below.

The last one setting the refinements is a surprise.
Example code
>> time-block [set [a b] [1 2]] 0,05
== 1.85012817382813e-7

>> time-block [set [a: b:] [1 2]] 0,05
== 1.92642211914063e-7

>> time-block [set [:a :b] [1 2]] 0,05
== 1.81198120117188e-7

>> time-block [set ['a 'b] [1 2]] 0,05
== 1.81198120117188e-7

>> set /a 1
== 1

>> set [/a] 1
** Script error: invalid argument: /a
** Where: set
** Near: set [/a] 1

Assigned ton/a Fixed in- Last Update24-Aug-2010 23:00


Comments
(0002470)
Carl
24-Aug-2010 22:54

There is nothing peculiar here. You are seeing the nanosecond differences from the order of tests in a line of C code.

A precise test is:

tick-time: time-tick .05
print system/version
recycle
a: time-block [set [x x x x x x x x x x] 1] 0,05
b: time-block [set [x: x: x: x: x: x: x: x: x: x:] 1] 0,05
c: time-block [set ['x 'x 'x 'x 'x 'x 'x 'x 'x 'x] 1] 0,05
print a - b
print a - c

2.100.103.3.1
-7.39097595214842e-9
-1.49011611938477e-8

Which shows that internally in the C code, an explicit test for WORD is first, then SET-WORD, then LIT-WORD.

Now, you may ask: why use explicit tests rather than bitmask AND of datatypes? (Which would cause all timings to be the same.) Answer is: for the most common case (WORD), the explicit test is faster than to setup the bitshift and do the AND.

Your second issue is different, and requires a separate ticket to be posted.

Date User Field Action Change
4-Nov-2010 15:23 Ladislav Comment : 0002462 Removed -
24-Aug-2010 23:00 carl Severity Modified minor => not a bug
24-Aug-2010 23:00 carl Status Modified submitted => dismissed
24-Aug-2010 22:58 carl Comment : 0002470 Modified -
24-Aug-2010 22:56 carl Comment : 0002470 Modified -
24-Aug-2010 22:54 carl Comment : 0002470 Modified -
24-Aug-2010 22:54 carl Comment : 0002470 Added -
1-Aug-2010 08:49 Ladislav Summary Modified Peculiar timing differences of the SET function => Peculiar timing differences and refinement handling of the SET function
1-Aug-2010 08:46 Ladislav Comment : 0002462 Added -
31-Jul-2010 23:26 BrianH Summary Modified Peculiarities of the SET function => Peculiar timing differences of the SET function
31-Jul-2010 23:26 BrianH Description Modified -
31-Jul-2010 23:26 BrianH Code Modified -
31-Jul-2010 23:26 BrianH Category Modified Unspecified => Native
26-Jul-2010 12:02 Ladislav Ticket Added -