Quantcast
Channel: Cadence Custom IC Skill Forum
Viewing all articles
Browse latest Browse all 5067

How NOT to slurp a file into SKILL....

$
0
0
;; Return the contents of FILE as a string... extremely slowly.
(defun BcmFileSlurpSlowly (file "t")
 (let (port line (lines ""))
   (unless (setq port (infile file))
      (error "Can't open %s" file))
    (while (gets line port)
      (setq lines (strcat lines line)))
    (close port)
    lines))

;; Return the contents of FILE as a string less slowly.
(defun BcmFileSlurpQuick (file "t")
  (let (port line lines)
    (unless (setq port (infile file))
      (error "Can't open %s" file))
    (while (gets line port)
      (push line lines))
    (close port)
    (buildString (reverse lines) "")))> (sh "ypcat passwd > /tmp/passwd")> (sh "wc -l /tmp/passwd")
39076 /tmp/passwd
t> measureTime (BcmFileSlurpSlowly "/tmp/passwd")
(207.8354 1.708741 209.6785 0)


Three and a half minutes for a 39 kiloLine file?! :O



> measureTime (BcmFileSlurpQuick "/tmp/passwd")
(0.06999 0.001 0.07150483 0)

That's better. :)

Questions:

  1. Why is strcat so much slower than push + buildString + reverse?
  2. Why doesn't allocate('string 39076) help make the strcat() method faster?
  3. Could this be done even more quickly than BcmFileSlurpQuick()? What is the fastest known way to slurp a file in SKILL?

Viewing all articles
Browse latest Browse all 5067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>