getc( ) and gets( ) speed

new topic     » topic index » view thread      » older message » newer message

Hello,                                                  
                                                        
Can the 1st example be made any faster than the second? 
                                                        
atom t, t1, t2, fn, lFileLen                            
integer lWS, lWE                                        
sequence lFile, line                                    
 
-- Example 1                                                       
--------------------------------------------------------
lFileLen = seek(fn, -1)                                 
lFileLen = where(fn)                                    
if seek(fn, 0) then end if                              
lFile = repeat(0, lFileLen + 1)                         
lFile[lFileLen+1] = crlf                                
                                                        
t1 = time()                                             
for i =1 to lFileLen do                                 
    lFile[i] = getc(fn)                                 
end for                                                 
                                                        
while lWE < lFileLen do                                 
   line = lFile[lWS..lWE])                              
   lWS = lWE + 1                                        
   lWE = lWS + 1                                        
end if                                                  
t2 = time()- t1                                         
--------------------------------------------------------
 
-- Example 2                                                                    
--------------------------------------------------------
t1 = time()                                             
for i = 1 to val[2]  do                                 
    line = gets(fn)                                     
    if atom(line) then                                  
       exit                                             
    end if                                              
    line = line[1..200]                                 
end for                                                 
t2 = time()- t1                                         
--------------------------------------------------------

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu