Page 1 of 1

Long time to read AC3 file

Posted: Sun Jul 31, 2005 2:55 am
by scurrie
Using the latest version I read an AC3 file that took 22 seconds so I ran it through APD and discovered 200,013 calls to substr. It turns out the calls were mostly in a tight loop in module.audio-video.mpeg.php line 43. I'm hoping there's a better way to find GETID3_MPEG_VIDEO_SEQUENCE_HEADER. Perhaps using strpos would be more efficient than walking a 200kB string 1 byte at a time. :wink:

For completeness here's the tracing from APD:

Code: Select all

getID3->analyze
  
  get_magic_quotes_runtime
  preg_match
  fopen
  filesize
  fseek
  ftell (2x)
  basename
  
  realpath
  str_replace
  getID3->IncludeDependency
    file_exists
    
      getID3->IncludeDependency
        file_exists
        
  getid3_id3v2->getid3_id3v2
    fseek
    fread
    substr
  getid3_id3v1->getid3_id3v1
    fseek
    fread (2x)
    substr (2x)
  
  getid3_apetag->getid3_apetag
    fseek
    fread
    
    substr
    
    substr
  
  getid3_lyrics3->getid3_lyrics3
    fseek
    fread
    substr (3x)
    strrev
    substr
    strrev (2x)
    substr
    strrev
  fseek
  fread
  getID3->GetFileFormat
    getID3->GetFileFormatArray
    preg_match (28x)
  file_exists
  
  
    getID3->IncludeDependency
      file_exists
      
        
     (8x)
  
  getid3_mpeg->getid3_mpeg
    fseek
    min
    fread
    
    substr (200001x)
  fclose

Code: Select all

Total Elapsed Time = 22.62
Total System Time  = 2.91
Total User Time    = 19.42

         Real         User        System             secs/    cumm
%Time (excl/cumm)  (excl/cumm)  (excl/cumm) Calls    call    s/call  Memory Usage Name
--------------------------------------------------------------------------------------
99.2 22.44 22.44  19.34 19.34  2.88 2.88  200013  0.0001   0.0001            0 substr