scale-bench 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env guile
  2. !#
  3. ;; -*- scheme -*-
  4. (use-modules (ice-9 match)
  5. (ice-9 threads)
  6. ((ice-9 rdelim) #:select (read-line))
  7. ((srfi srfi-1) #:select (filter-map append-map)))
  8. (define iteration-count 20)
  9. (define-syntax-rule (time exp)
  10. (let ((start (get-internal-real-time)))
  11. exp
  12. (let ((end (get-internal-real-time)))
  13. (/ (- end start) 1.0 internal-time-units-per-second))))
  14. (define (run-test ncores args)
  15. (time (apply system* "taskset" "-c" (format #f "0-~a" (1- ncores))
  16. args)))
  17. (define (main args)
  18. (format #t "Core count,~a\n" (string-join args " "))
  19. (let lp ((ncores 1))
  20. (when (<= ncores (total-processor-count))
  21. (let lp ((iteration 0))
  22. (when (< iteration iteration-count)
  23. (let ((result (run-test ncores args)))
  24. (format #t "~a,~a\n" ncores result))
  25. (force-output)
  26. (lp (1+ iteration))))
  27. (lp (1+ ncores)))))
  28. (when (batch-mode?)
  29. (match (program-arguments)
  30. ((_ script . args)
  31. (main (cons script args)))))