Author Topic: Another embeddable Scheme : KSI  (Read 6210 times)

0 Members and 1 Guest are viewing this topic.

RobbeK

  • Guest
Re: Another embeddable Scheme : KSI
« Reply #15 on: January 20, 2015, 01:36:21 AM »
Hi John,

"3 10ths of a second difference between compiled and interpretive doesn't seem that far apart for real world Lisp applications."
Yes, such is often the case with Lisp --  and both Mr Burger (PicoLisp) and Mr Müller (NewLISP) advocate not to compile Lisp (Lisp is no Lisp anymore then).  When I grab deep inside the trick box, I can outperform the compiled code with a script (rather tricky - using a trampoline).

;;---------------------------------------------   code

(define-macro (memoize mem-func func)
    (set (sym mem-func mem-func)
        (letex (f func  c mem-func)
          (lambda ()
              (or (context c (string (args)))
              (context c (string (args)) (apply f (args))))))))


(memoize fibo
    (lambda (n)
        (if(< n 2) 1L
            (+  (fibo (- n 1))
                (fibo (- n 2))))))

(define (trampoline-fibo)
   (for (i 100 35000 100) (fibo i)))

(println "Preprocessor time mSec :  " (string (time (trampoline-fibo))))
(println " ")

;;-----------------------------------------------------------  REPL
newLISP v.10.6.0 32-bit on Linux IPv4/6 libffi, options: newlisp -h

>
(lambda-macro (mem-func func) (set (sym mem-func mem-func)
  (letex (f func c mem-func) (lambda () (or (context c (string (args))) (context
      c
      (string (args))
      (apply f (args))))))))
(lambda () (or (context fibo (string (args))) (context fibo (string (args)) (apply
    (lambda (n)
     (if (< n 2)
      1L
      (+ (fibo (- n 1)) (fibo (- n 2)))))
    (args)))))
(lambda ()
 (for (i 100 35000 100)
  (fibo i)))
Preprocessor time mSec :  789.464


ALL THESE TIMES ARE IN mSec  !!!!
 
> (time (fibo 35000))
0.042
> (time (fibo 35080))
4.292
> (time (fibo 350))
0.033
> (fibo 3333)
2602001791620035102660281146254851368538134577547313243986650398107857603300640817062028986700348374060092104666895203262354335191902006922338311523958212035031166842325655478554701490041900891353189763644404566651329609855343896105990364882530440937097903699722199810916107782544414249474641090000091481681450849038014513682434512019540704125581163530283884634215821791912533189660388764337312692603320677721921556199717068989898476306660404192716460638148519631963617285912962827201164277381445818614845807992226707466270247983422302553505826546606498871498243201913503594282231848485960708607043944096551554975897349361970762742575283200711482837381395891074466146002661714634536225043650678287L

 8)
(i made anchor points in memory every 100 numbers  -- loss of speed 0.8 sec during start-up , that's all , further calculations give immediate results (till a certain limit , then new anchor points (trampolines) have to be build)

GNU/MIT Scheme ,  not yet, but now that I'm on Linux (finally) downloaded PicoLisp http://picolisp.com/wiki/?home  -- the Scalpel of Programming  ;)

best Rob

JRS

  • Guest
Re: Another embeddable Scheme : KSI
« Reply #16 on: January 20, 2015, 01:48:53 AM »
Quote
not yet, but now that I'm on Linux (finally)

I can vaguely remember my first week after moving my desktop to Linux. I'm happy to say I never looked back and treat Windows as a secondary OS others are still fond of.

 
« Last Edit: January 20, 2015, 04:10:03 PM by John »