2017-08-27

(sph test performance)

adaptive performance testing with formatted result display.

the minimum meaningful comparison run time can be specified

part of sph-lib

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 description

adapts the number of calls until a meaningful run time difference has been found

import name

(sph test performance)

exports

evaluate-performance

syntax

signature

minimum-seconds tests

sph-test-performance-description

variable

tags: programming guile documentation library scheme sph-lib q1 test test-performance highlight performance sph-test-performance