Skip to content

Commit

Permalink
tests: Add performance test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ambrevar committed May 31, 2023
1 parent 5f86b86 commit f8ffd10
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/tests.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,30 @@
internal-time-units-per-second))
(prompter:all-ready-p prompter)))))

(define-test spam-input ()
(let* ((suggestion-values '("foobar" "foobaz"))
(source (make-instance 'prompter:source
:name "Test source"
:constructor suggestion-values
;; :filter #'slow-identity-match
)))
(with-collected-prompter (prompter (prompter:make :sources source
:input-delay 0.005))
(let ((inputs (mapcar (lambda (&rest _)
(declare (ignore _))
(princ-to-string (random 100000)))
(alex:iota 100))))
(prompter:all-ready-p prompter)
(let ((before-input (get-internal-real-time)))
(dolist (input inputs)
(setf (prompter:input prompter) input))
;; Consecutive inputs happened fast enough
(assert-equality #'<
0.01 ; Slow ECL should be fine here even on a CI.
(/ (- (get-internal-real-time) before-input)
internal-time-units-per-second))
(prompter:all-ready-p prompter))))))

(define-test yes-no-prompt ()
(let* ((source (make-instance 'prompter:yes-no-source
:constructor '("no" "yes"))))
Expand Down

0 comments on commit f8ffd10

Please sign in to comment.