Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] [to] to block! vs to-block

From: pwawood:mango:my at: 18-Nov-2004 11:09

In the discussion about handling "untrusted" data, I noticed that Gabriele used "to block!" whilst Sunanda used to "to-block". I'm trying to understand if this is just a matter of personal preference or there is a real difference. On my machine, to block! appears to be at least 15 percent quicker than to-block as shown by the following timing test. The test isn't very accurate because I had other applications loaded on the machine at the time. I did run a loop of 25 timing tests and to block! was always quicker. Regards Peter
>> speedy: [
[ time-to-block: make time! 0 [ time-to: make time! 0 [ [ loop 100 [ [ start: now/time/precise [ loop 1000 [ to-block "12345" ] [ end: now/time/precise [ time-to-block: time-to-block + end - start [ [ start: now/time/precise [ loop 1000 [ to block! "12345" ] [ end: now/time/precise [ time-to: time-to + end - start [ ] ; end loop 100 [ print [ "average time for to-block" (time-to-block / 100) ] [ print [ "average time for to block!" (time-to / 100) ] [ ] == [ time-to-block: make time! 0 time-to: make time! 0 loop 100 [ start: now/time/precise loop 1000 ...
>> do speedy
average time for to-block 0:00:00.0067641 average time for to block! 0:00:00.00569063
>> do speedy
average time for to-block 0:00:00.00674169 average time for to block! 0:00:00.00503805
>> do speedy
average time for to-block 0:00:00.00682156 average time for to block! 0:00:00.00574013