#79363 - 2002-12-25 06:25 PM
4.20b1 Major Speed boost!
|
Bryce
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
|
|
|
|
#79365 - 2002-12-27 05:19 AM
Re: 4.20b1 Major Speed boost!
|
Bryce
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
Anonymous
Unregistered
|
Hey Bryce, Hows about posting that script over to the forum @ scriptlogic.com ? I'd love to see it syntax highlighted
-Brian
|
|
Top
|
|
|
|
#79367 - 2002-12-27 11:07 AM
Re: 4.20b1 Major Speed boost!
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
|
Top
|
|
|
|
Moderator: ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 1017 anonymous users online.
|
|
|