![]() |
READ$/Data Slow - Printable Version +- PowerBASIC Users Meeting Point (http://pump.richheimer.de) +-- Forum: User to User Discussions (http://pump.richheimer.de/forumdisplay.php?fid=3) +--- Forum: PowerBASIC for Windows (http://pump.richheimer.de/forumdisplay.php?fid=4) +--- Thread: READ$/Data Slow (/showthread.php?tid=97) |
READ$/Data Slow - Brent F Boshart - 11.10.2025 I have some data that I want to keep embedded in the code instead of an external file. This takes about 4 seconds to execute (the routines formatStarRA, formatStarDec and J2000Topo only account for about 0.3 seconds). I could make each line (element) one string padding with spaces and then using mid$ to parse it out. That would be 2400 READ$ instead of 2400*11. Any other suggestions to speed this up? FUNCTION DoubleStarLoad AS LONG LOCAL t AS LONG LOCAL tempRA, TempDec AS DOUBLE, dummy AS STRING FOR t= 0 TO 2399 DoubleStarData(t).CST=READ$((t)*11+1) DoubleStarData(t).ObjName=READ$((t)*11+2) DoubleStarData(t).SAO=READ$((t)*11+3) tempRA=formatStarRA(READ$((t)*11+4)) tempDec=formatStarDec(READ$((t)*11+5)) J2000Topo(tempRA,tempDec) DoubleStarData(t).RA=tempRA DoubleStarData(t).Dec=tempDec DoubleStarData(t).Magnitude1=READ$(t*11+6) DoubleStarData(t).Magnitude2=READ$(t*11+7) DoubleStarData(t).Spectral=READ$(t*11+9) DoubleStarData(t).Distance=VAL(READ$(t*11+10)) DoubleStarData(t).Separation=READ$(t*11+11) NEXT t DATA "Aqr","1 Aqr","126062","20:39:25","+00:29:11","5.27","12.3","7.03","K0III","71.48","65" DATA "Ari","1 Ari","74966","01:49:50","+22:15:45","16","17","1","M3.7+M4.2","","17.5" DATA "Ari","1 Ari","74966","01:50:09","+22:16:30","6.33","7.21","0.88","G3III","179.53","2.9" DATA "Boo","1 Boo","82942","13:40:40","+19:57:20","5.76","9.6","3.84","A1V","100.6","4.4" DATA "Cam","1 Cam","24672","04:32:02","+53:54:39","5.78","6.82","1.04","B0III","217.39","10.4" DATA "Del","1 Del","106172","20:30:18","+10:53:45","6.2","8.02","1.82","Be+B","227.79","0.9" DATA "Dra","1 Dra","15532","11:31:07","+69:24:00","14.3","14.8","0.5","","","1.2" .... END FUNCTION RE: READ$/Data Slow - Brent F Boshart - 11.10.2025 I reformatted the data to one string per line with a fixed length for each element. Much faster - I suppose 11x faster. RE: READ$/Data Slow - Dale Yarker - 11.10.2025 Lots of multiplying by 11. try this: ((this text belongs below the code. See Reason for edit.)) You said "... (the routines formatStarRA, formatStarDec and J2000Topo only account for about 0.3 seconds). 0.3 seconds may become significant with all *11 gone. If those functions are only called from DoubleStarLoad, then put their code as GOSUBs within DoubleStarLoad. Code: function DoubleStarLoad as long Posted while I was working: " I reformatted the data to one string per line with a fixed length for each element. Much faster - I suppose 11x faster." You got rid of the *11 another way. GOSUB suggestion still stands if they're only called from here. Cheers, RE: READ$/Data Slow - Stuart McLachlan - 11.10.2025 Populate the UDT array once and store it as ASMDATA? 1. Write a simple application to populate your array of UDT's and PUT it to a binary file. 2. Create an ASMDATA block from the file - see below. 3. Paste the ASMDATA in your application 4. In your main application, DIM DoubleStarData(num_of_records) AT CODEPTR(myASMData) Code: #COMPILE EXE "CreateASMDATA.exe" RE: READ$/Data Slow - Brent F Boshart - 11.10.2025 Thanks for the suggestions. Stuart, that is very clever - I will have to weigh the speed gained vs ease of code maintenance. I have my program initialization down from 12 seconds to 5 seconds - mainly by some initializing happening in a separate thread, so the user isn't staring at the splash screen too long. |