r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

Graham
17-May-2010
[16652]
but Ladislav is doing this 

1 1 23
Ladislav
17-May-2010
[16653]
yes, that (in R3) means, that the times obtained are in R3
Pekr
17-May-2010
[16654x2]
where do I get time-block from for R3?
where do I get time-block from for R3?
Ladislav
17-May-2010
[16656x2]
Write:

do http://www.fm.tul.cz/~ladislav/rebol/timblk.r
hmm, what does this mean? Is it intended? In R3:

>> exists? http://www.fm.tul.cz/~ladislav/rebol/timblk.r
== none
Pekr
17-May-2010
[16658x2]
Hmm, my version is much slower:

indices?-3: func [
        series [block!]
        value  [integer!] 
        /local result
][
        result: make series 0
        parse series [

               any [s: set wanted integer! (if value = wanted [append result index? 
               s])]
        ]
        result
]


>> time-block [indices?-1 blk 23] 0,05
== 0.000004669189453125

>> time-block [indices?-2 blk 23] 0,05
== 0.0000039520263671875

>> time-block [indices?-3 blk 23] 0,05
== 0.0000059661865234375
what is this dirty trick good for? :-)

1 1 value ???
Graham
17-May-2010
[16660]
It's because you can't match an integer like a word
Terry
17-May-2010
[16661x2]
looks like foreach is still the winner (on r2)
Against a block with 100,000 integers

Lad's : 0.047
foreach: 0.044
Ladislav
17-May-2010
[16663]
Terry, you did not write the Foreach-base algo here, so nobody can 
compare...
Graham
17-May-2010
[16664]
1 1 value means to run the rule once and only once where value is 
the rule
Pekr
17-May-2010
[16665]
A bit adapted Lad's version (does not use substraction):

indices?-4: func [
	series [series!]
	value
	/local result
] [
	result: make series 0
	parse series [
		any [series: 1 1 value (append result index? series) | skip]
	]
	result
]


>> time-block [indices?-2 blk 23] 0,05
== 0.000003936767578125

>> time-block [indices?-4 blk 23] 0,05
== 0.000003753662109375
Ladislav
17-May-2010
[16666x2]
interesting, I thought, that this modification would be slower
(index?-2 spares four assignments, while index?-4 spares two subtract 
calls)
Terry
17-May-2010
[16668x2]
what are your results compared to foreach?
gotta go.. bedtime in the pacific northwest
Pekr
17-May-2010
[16670x3]
Is there any other way of how to put word in, instead of 1 1 value? 
Quote? Hmm, probably not ... I don't like the form ....
if we have 'set, we could have 'get, no?
Replacing "1 1 value" by "quote (value)" as variant 5:

indices?-5: func [
	series [series!]
	value
	/local result
] [
	result: make series 0
	parse series [

  any [series: quote (value) (append result index? series) | skip]
	]
	result
]

>> time-block [indices?-1 blk 23] 0,05
== 0.0000047607421875

>> time-block [indices?-2 blk 23] 0,05
== 0.000003936767578125

>> time-block [indices?-3 blk 23] 0,05
== 0.0000059814453125

>> time-block [indices?-4 blk 23] 0,05
== 0.00000372314453125

>> time-block [indices?-5 blk 23] 0,05
== 0.000003692626953125
Graham
17-May-2010
[16673x2]
Nice .. we don't have quote in r2
Wonder if that could be back ported to r2 ...
Pekr
17-May-2010
[16675]
Matrix - There is no spoon ...
REBOL - There is no R2 ....

... forget R2 :-)
Graham
17-May-2010
[16676]
Brian will object anyway ...
Pekr
17-May-2010
[16677]
I think that backporting parse, which is totally rewritten for R3, 
is really meaningless waste of energy ...
Graham
17-May-2010
[16678x2]
except for those of us using R2
Remember that we are paying R2 customers .. and R3 is not going to 
be usable for a few more years
Pekr
17-May-2010
[16680]
If you would not use GUI, what exactly would be holding you back? 
You created even basic networking schemes? As for me, I miss fixed 
'call - it is still hugely crippled and absolutly useless ...
Graham
17-May-2010
[16681]
I don't do any non gui apps
Pekr
17-May-2010
[16682]
Graham - that is nonsense, no? I mean - not being usable for few 
more years ... but we should move the discussion to R3, or advocacy 
...
Graham
17-May-2010
[16683x2]
Pekr, it's still alpha!
It took 4 years to reach alpha
Pekr
17-May-2010
[16685x3]
e.g. for me, RebGUI is a dead end. I talked to Bobik, and he is back 
to VID for simple stuff. There were many changes lately, and some 
things got broken, and it does not seem to be supported anymore. 
As for GUI, I believe that in 2-3 months, you will be able to talk 
otherwise, as Robert wants to move his tools to R3 definitely ...
I don't care about the stickers. Someone said it is alpha, so tell 
to your brain, that it is a beta, and you are OK, easy as that :-) 
I use products according to functionality, not its official alpha/beta/theta 
status ...
I used Mozilla since 0.96 and it worked for me :-)
Graham
17-May-2010
[16688]
sorry, it's still alpha quality
Gabriele
17-May-2010
[16689]
Henrik: ahttp works basically like async:// - there are no docs other 
than the Detective sources.
Terry
17-May-2010
[16690x3]
Cheyenne is R2. I need something that works with it.
>> a

== [23 43 55 28 345 99 320 48 22 23 95 884 1000000 999999 999998 
999997 999996 999995 999994 999993 999992 999991 999990 999989 999...
>>

(a is a block with 1, 000,012  integers) 


ind: func[series value x][


	st: now/time/precise
		
	while [x > 0][
		
		result: make series 0
		series: head series

  parse series[any [series: 1 1 value (append result index? series) 
  | skip]] 
		x: x - 1
	]
	et: now/time/precise
	fin: et - st
	print fin
	result 
]

feach: func[series value x][

	result: make series 0 
	st: now/time/precise
	
	while [x > 0][

  foreach[s p v] series [if s = value [append result reduce [s p v]]]
		x: x - 1
	]
	et: now/time/precise
	fin: et - st
	print fin
	result 
]

>> ind a 23 10
0:00:01.249
== [1 10 999990]
>>

>> feach a 23 10
0:00:01.01

== [23 43 55 23 95 884 23 43 55 23 95 884 23 43 55 23 95 884 23 43 
55 23 95 884 23 43 55 23 95 884 23 43 55 23 95 884 23 43 55 23 9...
>>

10 iterations each.. 


foreach is the winner speed wise.. as a bonus, If i use foreach, 
I don't need the index?
Still this is too slow.. it's fine for 1M data, but 10M and it grinds 
hard.

.. there must be a faster way to find integers in a block (or hash) 
using SELECT, FIND or INDEX?
Maxim
17-May-2010
[16693x7]
yes... you do a find, within a while block.   that was the fastest 
loop I did for matching exact SAME? strings.  I'd bet its the best 
here too.
or did you test that already?
the problem is that with hash! find will return both keys and data 
though.
also, until is a bit faster than while IIRC.
might want to refer to this big loop analysis I did last year...


http://www.pointillistic.com/open-REBOL/moa/scream/rebol-iterator-comparison.txt
you'd be surprised that the fastest search method is remove-each 
(if you account for inserting/appending as part of the loop).   but 
you'll need to copy the initial block each time, which might take 
its own time.
in your tests, this causes your loops to slow down a lot:

result: make series 0

you should:

result: make series length? series. 


because when appending, you will be re-allocating the result over 
and over... and the GC is the loop killer in every single big dataset 
tests I've done.  not because its bad, per se, but because you are 
forcing it to operate.
Terry
17-May-2010
[16700]
Thanks Maxim, I'll check it out.
Maxim
17-May-2010
[16701]
I'm building a little example which I think will outperform your 
examples... I'm curious.