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

World: r3wp

[!REBOL3-OLD1]

BrianH
7-Feb-2009
[10662]
I posted it above as FILEIZE, but here:

undirize: func [
	{Returns a copy of the path with any trailing "/" removed.}
	path [file! string! url!]
][
	path: copy path
	if #"/" = last path [clear back tail path]
	path
]
[unknown: 5]
7-Feb-2009
[10663x2]
undirize: func [file [file! sring! url!]][if #"/" = last file [reverse 
remove reverse file]]
typo
BrianH
7-Feb-2009
[10665]
Ouch, two reverses :(
[unknown: 5]
7-Feb-2009
[10666x2]
yeah
Works well.
BrianH
7-Feb-2009
[10668]
I don't doubt it. It is modifying rather than copying, but it looks 
like it works.
[unknown: 5]
7-Feb-2009
[10669]
Yeah and at less evals then yours.
BrianH
7-Feb-2009
[10670]
head clear back tail is much faster than reverse remove reverse. 
All of that reversing is series copying, as is remove from the head 
of a series. If you don't need your function to copy, change reverse 
remove reverse to clear back tail.
[unknown: 5]
7-Feb-2009
[10671]
See already hammering out better code by talking about it.
BrianH
7-Feb-2009
[10672]
Yup :). Also, the return value of mine matters, as it does with DIRIZE, 
while yours is tossed. You wouldn't be able to use yours as a swap-in 
replacement for DIRIZE for non-dirs. Mine is a function, while yours 
is more of a procedure (making the Pascal distinction).
[unknown: 5]
7-Feb-2009
[10673x3]
I wouldn't use mine at all for myself ;-)
I'm getting to where I use less and less mezzanines.
At least for the more simply things.
BrianH
7-Feb-2009
[10676x3]
If you add a file on the end of the function you would have a useful 
return value. Then the only difference would be the copying.
My approach is to improve the mezzanines to the point where it actually 
makes sense to use them instead of optimizing them away, or at least 
to the point where their code is good enough to inline. If I don't 
use it in highly optimized code, it doesn't go in.
The simpler and faster I can make them the better. If this means 
imporovements to the natives to make the mezzanines better, then 
any code you write that also uses the natives will also be better. 
And you get good library funnctions too :)
[unknown: 5]
7-Feb-2009
[10679]
;Just using remove


undirize: func [file [file! string! url!]][if #"/" = last file [remove 
back tail file] file]
BrianH
7-Feb-2009
[10680]
We should profile to see which is faster: remove or clear.
[unknown: 5]
7-Feb-2009
[10681]
The remove is better.
BrianH
7-Feb-2009
[10682x2]
They are within variance of each other in this case. Interchangeable. 
After multiple runs, both get faster times than the other.
Which is weird, because REMOVE does more work than CLEAR, what with 
the refinement checking.
[unknown: 5]
7-Feb-2009
[10684]
I think it is the amount of movement via the index that is time consuming 
for the other method.
BrianH
7-Feb-2009
[10685]
That would be the same with both. Well, remove is easier to undeerstand 
than clear, so it's a good choice.
[unknown: 5]
7-Feb-2009
[10686]
Clear might have a lot of underlying code for ports use as well which 
may be the reason why remove is better.
BrianH
7-Feb-2009
[10687x2]
Nah, both are actions so there is no type-specific overhead that 
affects use with other types.
And I didn't fine remove to be better consistently. Clear won half 
the time with the same code.
[unknown: 5]
7-Feb-2009
[10689x2]
I don't know.  That is why we profile.  ;-)
The remove is more CLEAR to understand.  Pun intended.
BrianH
7-Feb-2009
[10691x2]
I ran a dozen profiles of each, and they were 50/50 on which was 
faster. That is well within the profiler variance.
I submitted a tweak to dp that improves the accuracy, but the profiler 
is too inconsistent to time differences this small well enough.
[unknown: 5]
7-Feb-2009
[10693]
Well you definately want to make sure your profiler works.
BrianH
7-Feb-2009
[10694x2]
It works for big differences well enough (based on my testing).
For instance, that /into proposal was based on huge differences picked 
up by the profiler. If implemented it could eventually lead to user-visible 
reductions in overhead. That's a big deal.
[unknown: 5]
7-Feb-2009
[10696]
When profiling traversal operations, I have experienced skewed results.
BrianH
7-Feb-2009
[10697]
Interesting. Examples?
[unknown: 5]
7-Feb-2009
[10698x2]
Well, my get-block function is an example.  I used it on a series 
of block data and get different results that don't seem to jive with 
my expectations.
Some more complex reads actually resulted in better performance then 
less complex reads.
BrianH
7-Feb-2009
[10700]
Are you talking about file access?
[unknown: 5]
7-Feb-2009
[10701x2]
I had done a test where I read a small 5000 record file and compared 
to a 100000 record file and the 100000 record file proviled better 
performance than the smaller one.
After the file read.
BrianH
7-Feb-2009
[10703]
Sounds like cache is a factor here.
[unknown: 5]
7-Feb-2009
[10704x3]
http://www.tretbase.com/forum/viewtopic.php?f=8&t=30#p131
That function.
Cache is definately a factor in those type of operations.
BrianH
7-Feb-2009
[10707]
Looks like parse could help with the speed, but it might be harder 
to get it right.
[unknown: 5]
7-Feb-2009
[10708x2]
I started to go that route but started getting bad performance so 
I went this route utilizing find.
It was most likely an implementation detail as find I assume uses 
parse.
BrianH
7-Feb-2009
[10710]
Nope. FIND is faster than PARSE, but PARSE is faster than FIND with 
WHILE.
[unknown: 5]
7-Feb-2009
[10711]
And while is slower than until and foreach.  It gets complicated.