[REBOL] Re: Profiling Rebol API to DyBASE
From: knizhnik:garret:ru at: 19-Dec-2003 1:22
Hello Gregg,
I was able to isolate the problem.
The following script shows almost the same time as testindex.r
searching for 200000 objects.
n: 200000
h: make hash! n
start: now/time/precise
repeat i n [
oid: random n
obj: select h oid
if none? obj [
obj: make object! [__oid__: oid]
insert insert tail h oid obj
]
if (i // 100) = 0 [clear h]
]
print ["Elapsed time for adding" n "records" (now/time/precise - start)]
At my computer execution of this script takes about 70 seconds.
By replacing it with:
n: 200000
h: make hash! n
l: make block! n
start: now/time/precise
repeat i n [
oid: random n
pos: find h oid
either none? pos [
obj: make object! [__oid__: oid]
insert tail h oid
insert tail l obj
] [obj: pick l index? pos]
if (i // 100) = 0 [clear h clear l]
]
print ["Elapsed time for adding" n "records" (now/time/precise - start)]
I was able to reduce execution time till 33 seconds.
Are there some better ideas how to improve performance of this peace
of code?
Thursday, December 18, 2003, 11:46:41 PM, you wrote:
GI> Hi Konstantin,
KK>> So, during index search 1.5 minutes from 2 were spent in lookup
KK>> function. And 14 seconds takes searching index itself.
KK>> From these 1.5 minutes most of the time was spent in this line:
KK>> obj: select obj-by-oid-map oid
GI> A quick test seems to show that the SELECT part of the lookup is
GI> faster for smaller numbers of records (e.g. 10,000), and gets
GI> progressively slower as the numbers increase. That is, it starts out
GI> faster than the FETCH and MAKE parts and ends up a lot slower than
GI> they are with larger numbers of records.
GI> -- Gregg
--
Best regards,
Konstantin mailto:[knizhnik--garret--ru]