This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

grep


What is the fastest grep?

I tried this:

(use-modules (ice-9 slib))
(require 'string-search)

(define (grep search-string filename)
  (letrec ((grep* (lambda()
		    (let ((line (read-line)))
		      (if (not (eof-object? line))
			  (begin (if (substring? search-string line)
				     (begin (display line)
					    (newline)))
				 (grep*)))))))
    (with-input-from-file filename grep*)))

But the performance is terrible:

real    1m34.139s
user    1m33.890s
sys     0m0.220s

compared to the normal grep:

real    0m0.198s
user    0m0.050s
sys     0m0.090s