2023-02-27

itml2md

(sph test performance)

#(library-short-description (sph test performance))

the minimum meaningful comparison run time can be specified part of #(link-c-one ("sph-lib" "start" "overview"))

example

setup

(import (rnrs bytevectors) (srfi srfi-1)
  (ice-9 regex) (sph) (sph string) (sph one) (sph test performance))

(define regular-string (string-multiply "12" 300))
(define varied-string
  (list->string (map! integer->char (map! (l (ele) (+ 10 (random ele))) (make-list 300 200)))))

(define (test-match-regular n) (regexp-replace regular-string "12" "121212"))
(define (test-match-varied n) (regexp-replace varied-string "12" "121212"))
(define (test-replace-regular n) (string-replace-string regular-string "12" "121212"))
(define (test-replace-varied n) (string-replace-string varied-string "12" "121212"))

(evaluate-performance 2 test-match-regular
  test-match-varied test-replace-regular test-replace-varied)

output

name                      time                      faster than slowest
------------------------------------------------------------------------------
1. replace-varied         20                        1309.3x
2. match-varied           150                       182.3x
3. replace-regular        1330                      19.7x
4. match-regular          27489                     0.0x
#(library-documentation (sph test performance))