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 ()
    (make-date
     0
     (random 60)
     (random 60)
     (random 24)
     (+ 1 (random 27))
     (+ 1 (random 12))
     (+ 2000 (random 10))
     0)))

(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

_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to