Page 1 of 1 1
Topic Options
#79363 - 2002-12-25 06:25 PM 4.20b1 Major Speed boost!
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
wow, running 4.20b1 on some of my scripts! major speed boost for dealing with large internal arrays!

quote:
under 4.12

Downloading Inventory Database..done 11:16:06
Building Inventory Database..done 11:17:26
Saving Inventory Database..Done 11:17:31

under 4.20 b1

Downloading Inventory Database..done 11:19:00
Building Inventory Database..done 11:19:23
Saving Inventory Database..Done 11:19:25

the database file being downloaded is 172k flat text file that i load into an arry. Once loaded into an array i think i have to loop throught at least twice.

before this process took on my 700mhz celeron a little over a min using 4.12 using the same code but running 4.20b1 the whole thing gets done in about 30sec!

[ 27. December 2002, 01:12: Message edited by: LLigetfa ]

Top
#79364 - 2002-12-27 01:11 AM Re: 4.20b1 Major Speed boost!
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
But your topic title says 4.020b1... mind if I correct?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#79365 - 2002-12-27 05:19 AM Re: 4.20b1 Major Speed boost!
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
not at all!

and for those who are intersting in what in the hell i am doing.... here is the code.

code:
break on
;if exist(".\inventoryengine.kix") del".\inventoryengine.kix" endif
$database = "HKEY_CURRENT_USER\Software\OPDB"

PutDB($database,"status","Inventory","@time,BUSY")
$Inventory = loadinventory()
? "Saving Inventory Database.."
;[0] = "Station name"
;[1] = "name of equipment"
;[2] = "ammount in station
;[3] = "current cost"
for each $line in $inventory
$line = split($line,",")
if getdb($database,"status","Inventory") = "abort" or getdb($database,"Status","pnum") <> $pnum
quit
endif

if not keyexist($database + "\inventory\current\" + $line[0])
$ = addkey($database + "\inventory\current\" + $line[0])
endif
putdb($database,"inventory\current\" + $line[0], $line[1], $line[2] + "," + $line[3])
next
PutDB($database,"status","Inventory","@time,IDLE")
"Done @time"
exit(0)

function PutDB($database,$section,$key,$data)
dim $nul
$nul = writevalue($database + "\" + $section,$key,$data,"REG_SZ")
exit(@error)
endfunction

function GetDB($database,$section,$key)
$getdb = readvalue($database + "\" + $section,$key)
exit(@error)
endfunction


Function LoadInventory
dim $inventory, $InvLine, $etw, $ctw, $stw, $count, $commod, $equipment, $station, $line

dim $temparray[10]

if not $josshdownload
$josshdownload = createobject("microsoft.xmlhttp")

if @Error <> 0
exit(@error)
endif
endif


? "Downloading Inventory Databasae.."
$josshdownload.open("GET", "http://jumpgate.netdevil.com/database/inventory/inventory.txt",not 1)
$josshdownload.send

"done @time"

? "Building Inventory Database.."
if $josshdownload.responsetext
$inventory = split($josshdownload.responsetext,@crlf)
;if ubound($inventory) <> 4447
; exit(1)
;else
; redim preserve $inventory[ubound($inventory)-1]
;endif

$ETW = loadequipment(".\equipment.dat")
$CTw = loadcommods(".\commods.dat")
$STW = loadstations(".\stations.dat")

;$invline[0] = "Station name"
;$invline[1] = "type of inventory"
;$invline[2] = "name of equipment"
;$invline[3] = "ammount in station
;$invline[4] = "current cost"
for $line = 0 to ubound($inventory)
$InvLine = split($inventory[$line],",")
if ubound($invline) = 4
if getdb($database,"status","Inventory") = "abort" or getdb($database,"Status","pnum") <> $pnum
quit
endif
for each $station in $STW
if $station = $invline[0]
select
case $invline[1] = "commodity"
for each $commod in $CTW
if $commod = $invline[2]
if $count > ubound($temparray)
redim preserve $temparray[ubound($temparray)+20]
endif
$temparray[$count] = $invline[0] + "," + $invline[2] + "," + $invline[3] + "," + $invline[4]
$count = $count + 1
endif
next
case 1
for each $equipment in $ETW
if $equipment = $invline[2]
if $count > ubound($temparray)
redim preserve $temparray[ubound($temparray)+20]
endif
$temparray[$count] = $invline[0] + "," + $invline[2] + "," + $invline[3] + "," + $invline[4]
$count = $count + 1
endif
next
endselect
endif
next
endif
next
if $count = 0
$inv = ""
else
redim preserve $temparray[$count-1]
endif

"done @time"

endif
$LoadInventory = $temparray
endfunction

function Loadequipment($file)
dim $nul, $count

dim $temp[5]

$nul = open(1,$file)
while not @error
$temp[$count] = readline(1)
if substr($temp[$count],1,1) <> ";" and $temp[$count] <> ""
$count = $count+1
endif
if $count > ubound($temp)
redim preserve $temp[ubound($temp)+10]
endif
loop
if $count > 0
redim preserve $temp[$count - 1]
else
$temp = ""
endif
$loadequipment = $temp
$ = close(1)
endfunction

function LoadStations($file)
dim $nul, $count

dim $temp[5]

$nul =open(1,$file)
while not @error
$temp[$count] = readline(1)
if substr($temp[$count],1,1) <> ";" and $temp[$count] <> ""
$count = $count+1
endif
if $count > ubound($temp)
redim preserve $temp[ubound($temp)+10]
endif
loop
if $count > 0
redim preserve $temp[$count - 1]
else
$temp = ""
endif
$loadstations = $temp
$ = close(1)
endfunction

function LoadCommods($file)
dim $nul, $count

dim $temp[5]

$nul = open(1,$file)
while not @error
$temp[$count] = readline(1)
if substr($temp[$count],1,1) <> ";" and $temp[$count] <> ""
$count = $count+1
endif
if $count > ubound($temp)
redim preserve $temp[ubound($temp)+10]
endif
loop
if $count > 0
redim preserve $temp[$count - 1]
else
$temp = ""
endif
$loadcommods = $temp
$ = close(1)
endfunction

you also need the 3 .cfg files..... in the same folder...

commods.dat
equipment.dat
stations.dat

Top
#79366 - 2002-12-27 06:40 AM Re: 4.20b1 Major Speed boost!
Anonymous
Unregistered


Hey Bryce,
Hows about posting that script over to the forum @ scriptlogic.com ? I'd love to see it syntax highlighted [Wink]

-Brian

Top
#79367 - 2002-12-27 11:07 AM Re: 4.20b1 Major Speed boost!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Wait a bit Brian [Wink]

I am back from my holidays (short but stress) and also back on my keaboard ... so UBBPostprep.kix should be usable at the end of the year ( [Wink] )

J.
_________________________



Top
#79368 - 2002-12-27 11:48 AM Re: 4.20b1 Major Speed boost!
Wizard Offline
Hey THIS is FUN
*****

Registered: 2000-12-05
Posts: 264
Loc: Bristol, England
Cool, so what are the differences between 4.12 and 4.20b1 ??

How come the increase in speed ?

W
_________________________
Wizard
There's no place like 127.0.0.1

vb | kix | batch | html | cfm | js | english

Top
#79369 - 2002-12-28 09:26 AM Re: 4.20b1 Major Speed boost!
Anonymous
Unregistered


Wizard,
You can always read up on what's going on, including the changes from version to version at:
http://www.scriptlogic.com/KiXtart/DevReport.asp

Top
#79370 - 2002-12-31 03:26 AM Re: 4.20b1 Major Speed boost!
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
this ofcourse is speed up in some cases.
found some intence script which run about 10mins and the speed up was about 10s...

so, something has gotten faster... not everything.
_________________________
!

download KiXnet

Top
#79371 - 2002-12-31 05:58 AM Re: 4.20b1 Major Speed boost!
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
in my above example i am taking 1 173k text file feeding it into an array, i then compare this BIG 173k array against 3 small arrays to populate a database.

Since the 3 smaller arrays are user defined they are not hard coded so i have to give up processing speed for flexibility...

also the larger array has a delimited data in each line that i have to split and make comparisons against data in the 3 smaller arrays.....

looks like the internal working at least when dealing with arrays has benefited greatly from 4.20

If i may ask, what are you doing in this 10min process??

Top
#79372 - 2002-12-31 06:16 AM Re: 4.20b1 Major Speed boost!
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
translating text2html.
I had some other test code too, with a lot of looping with predefined strings and it's time wasn't reduced so much either...

just can't remember what the heck it was...

[ 31. December 2002, 06:18: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1013 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.058 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.