Hi Ted,
>On 1/4/2000 at 5:37 PM [EMAIL PROTECTED] wrote:
>
>"since all you have to do is compare two pointers to memory and two
>indexes."
>
>Most of us don't have access to the implementation details, so it's
>hard to say what REBOL has to do. All we can see is what it does.
I guess it was really a rhetorical question, but one could speculate, such as
"to make this more efficient this other more important thing would become
less efficient ..." I don't really know enough to even speculate ...
>Cool experiment, though.
>
>Do you get any different results using functions rather than operators?
With something like comparing long strings the difference between functions
and operators isn't going to show up. So with integers:
>> time-it [loop 10'000'000 [1 = 2]]
0:00:11
>> time-it [loop 10'000'000 [equal? 1 2]]
0:00:15
>> time-it [loop 10'000'000 [= 1 2]]
0:00:15
I'd assumed that since operators require special syntactic processing, they'd
be slower, but it seems they're faster when used as infixes, but just the
same as functions when used as prefixes.
>Do you get different results with larger and smaller loops? Larger and
>small strings?
Hmmm...
>> c: copy b: a: head insert/dup "" "a" 100'000 print "done"
done
>> time-it [loop 5000 [a = b]]
0:00:13
>> time-it [loop 10000 [a = b]]
0:00:26
>> c: copy b: a: head insert/dup "" "a" 200'000 print "done"
done
>> time-it [loop 5000 [a = b]]
0:00:26
>> c: copy b: a: head insert/dup "" "a" 400'000 print "done"
done
>> time-it [loop 5000 [a = b]]
0:00:50
Looks like the time it takes is pretty much proportional to the length of the
loop and the length of the strings.
>Do you get different results with operations other than comparison?
Hmmm ... I tried copying some long strings 5000 times and it started
thrashing my disk. Let's restart REBOL and let it settle down a bit ...
>> a: head insert/dup "" "a" 100'000 print "done"
done
>> time-it [loop 5'000'000 [length? a]]
0:00:05
>> a: head insert/dup "" "a" 200000 print "done"
done
>> time-it [loop 5'000'000 [length? a]]
0:00:06
>> a: head insert/dup "" "a" 400'000 print "done"
done
>> time-it [loop 5'000'000 [length? a]]
0:00:07
Well, LENGTH? is very fast, and the time increases with length, but not
proportionally. Perhaps the loop overhead is a large factor here?
Don't try clocking REBOL operations with FOR loops, cause that'll be almost
pure overhead.
>Do you get different results with greater or fewer words defined?
That's a good question!
Fresh REBOL, no scripts loaded from user.r:
>> a: copy "aaaaaaaaaa"
== "aaaaaaaaaa"
>> b: copy a
== "aaaaaaaaaa"
>> time-it [loop 10000000 [a = b]]
0:00:17
>> for x 1 500 1 [set to word! join "a" x copy a]
== "aaaaaaaaaa"
>> a499
== "aaaaaaaaaa"
>> time-it [loop 10000000 [a = b]]
0:00:17
Doesn't seem to make much difference. BTW, as I posted to the list a couple
of weeks ago, there's a limit of 1,534 definable words, so it's hard to push
it here. I got a message back from Bo saying that the problem had been
noticed before, and that he'd opened an incident on it, so maybe we'll be
able to use more words in the future.
>What's the source of time-it?
>> source time-it
time-it: func [
"time execution of a block"
block [block!]
/local t
][
t: now/time
do block
print now/time - t
]
Larry's the expert on timing things. (He'll also tell you some interesting
stuff about memory usage if you ask.) His TIC and TOC are much cooler than my
TIME-IT. I just got in the habit of using TIME-IT, which isn't as flexible,
but OK for simple things.
>
>-Ted.
Nice talking to you,
Eric
>*********** REPLY SEPARATOR ***********
>
>On 1/4/2000 at 5:37 PM [EMAIL PROTECTED] wrote:
>
>Hi there,
>
>One thing I find very puzzling on this subject:
>
>>> c: copy b: a: head insert/dup "" "a" 100000 print "done"
>done
>>> time-it [loop 5000 [a = b]] ; 1) should be done very fast
>0:00:15
>>> time-it [loop 5000 [a = c]] ; 2) takes time, of course
>0:00:19
>>> time-it [loop 5000 [a =? b]] ; 3) should be done very fast
>0:00:15
>>> time-it [loop 5000 [a =? c]] ; 4) should be done very fast
>0:00:18
>
>=? is the operator for SAME?
>
>2) takes time because 100,000 characters have to be compared. But it should
>take almost no time at all to determine if two string values are the "same",
>as in 3) and 4), since all you have to do is compare two pointers to memory
>and two indexes. Likewise, if two values are the "same", they must be equal,
>so ideally 1) should be fast as well. So why doesn't REBOL do this a little
>more efficiently?
>
>See you,
>Eric