;Benchmark:
;CL-USER> (time (loop repeat 100000 do (generate-random-text 100)))
;Evaluation took:
; 1.375 seconds of real time
; 1.375000 seconds of total run time (1.375000 user, 0.000000 system)
; [ Run times consist of 0.080 seconds GC time, and 1.295 seconds non-GC time. ]
; 100.00% CPU
; 3,299,809,761 processor cycles
; 136,798,984 bytes consed
;;; Here's a slightly more efficient implementation:
(defun generate-random-text (length &optional (valid-chars +valid-chars+))
(let ((string (make-string length)))
(dotimes (i length)
(setf (aref string i) (pick-random valid-chars)))))
;CL-USER> (time (loop repeat 100000 do (generate-random-text 100)))
;Evaluation took:
; 0.703 seconds of real time
; 0.703125 seconds of total run time (0.687500 user, 0.015625 system)
; 100.00% CPU
; 1,684,737,900 processor cycles
; 41,602,096 bytes consed