;; start the repl and then load this file

(define start-time (current-seconds))

(let loop ((last-print 0)
	   (num-calls  0))
  (let ((all-run-ids (rmt:get-all-run-ids))
	(do-print    (> (- (current-seconds) last-print) 2))
	(max-query   0))
    (for-each
     (lambda (run-id)
       ;; (rmt:get-tests-for-run run-id testpatt states statuses offset limit not-in sort-by sort-order qryvals last-update mode)
       (let* ((all-run-data (rmt:get-tests-for-run run-id "%" '() '() #f #f #f #f #f #f #f #f)))
	 (for-each
	  (lambda (testdat)
	    (let* ((test-id (vector-ref testdat 0))
		   (start-at (current-milliseconds))
		   (testinfo (rmt:get-test-info-by-id run-id test-id))
		   (query-time (- (current-milliseconds) start-at)))
	      (if (> query-time max-query)
		  (set! max-query query-time))))
	  all-run-data)
	 (if do-print
	     (print "Running "(- (current-seconds) start-time)"s, run "run-id" has "(length all-run-data)" tests, max query "max-query))))
     all-run-ids)
    (loop (if do-print
	      (current-seconds)
	      last-print)
	  (+ num-calls (length all-run-ids)))))

