Megatest

load-the-db.scm at [13060ce126]
Login

File utils/load-the-db.scm artifact 92b9fb2b93 part of check-in 13060ce126


;; 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)
	 (num-calls   (+ num-calls
			 1                    ;; account for call above
			 (length all-run-ids) ;; account for the get-tests-for-run in the for-each below
			 )))
    (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)))
	 (set! num-calls (+ num-calls (length all-run-data)))
	 (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
	     (let* ((run-time (- (current-seconds) start-time))
		    (qry-rate (if (> run-time 0)
				  (inexact->exact (round (/  num-calls run-time)))
				  -1)))
		(print "Running "run-time"s, run "run-id
		    " has "(length all-run-data)" tests, max query "max-query
		    "ms with avg query rate "qry-rate" qry/s")))))
     all-run-ids)
    (loop (if do-print
	      (current-seconds)
	      last-print)
	  num-calls)))