Following is my quicksort program in Scheme using Racket and I'd like to measure time this program but I cannot find a way to do that.
I tried (time(quicksort(list 1 4 3)))
but this is not as precise as I expected. Is there any ideal way to do this?
#lang racket
(define (partition compare lst)
(cond
((null? lst) '())
((compare (car lst)) (cons (car lst) (partition compare (cdr lst))))
(else (partition compare (cdr lst)))))
(define (quicksort lst)
(cond
((null? lst) '())
(else (let ((pivot (car lst)))
(append (append (quicksort (partition (lambda (x) (< x pivot)) lst))
(partition (lambda (x) (= x pivot)) lst))
(quicksort (partition (lambda (x) (> x pivot)) lst)))))))