[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] date comparison is very, very, very slow (srfi-19)

From: Anthony Carrico
Subject: [Chicken-users] date comparison is very, very, very slow (srfi-19)
Date: Wed, 24 Sep 2008 14:33:49 -0400
User-agent: Mozilla-Thunderbird (X11/20080509)

I ran into an extreme slowdown with some code that uses dates. I thought
this was a complexity issue with sorting, or something like that, but I
noticed that it was mainly GC, and traced it to date<?.

Date comparison is done on julian-days, which are cached in dates, so it
is simplest to observe by running date->julian-day over some random dates.

The following code takes 16sec to do the equivalent of 1000 date
comparisons on an AMD Athlon(tm) X2 Dual Core Processor BE-2400:

(require-extension srfi-19) ;; time

(define random-date
  (lambda ()
     (random 60)
     (random 60)
     (random 24)
     (+ 1 (random 27))
     (+ 1 (random 12))
     (+ 2000 (random 10))

(define random-dates
  (lambda (n)
    (map (lambda (ignore) (random-date)) (make-list n))))

(time (map date->julian-day (random-dates 2000)))

$ csc ox-date.scm
$ ./ox-date
  16.393 seconds elapsed
  16.117 seconds in (major) GC
    8272 mutations
       0 minor GCs
    7681 major GCs

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]