Исправление tp_for_my_bunghole, (текущая версия) :
Emacs Lisp.
~41.504390 seconds;
Интересно, производительность на уровне интерпретатора Python со __slots__ в классе, это очень хорошо.
(defvar *times*)
(setq *times* (* 100 1000 1000))
(defstruct (el-test-struct (:type vector))
next fld1 fld2 fld3 fld4 fld5)
(defun el-test-inner (o n)
(let ((res 0))
(dotimes (i n)
(incf res (el-test-struct-fld1 o))
(setf (el-test-struct-fld2 o) (el-test-struct-fld1 o)
(el-test-struct-fld3 o) (el-test-struct-fld2 o)
(el-test-struct-fld4 o) (el-test-struct-fld3 o)
(el-test-struct-fld5 o) (el-test-struct-fld4 o)
(el-test-struct-fld1 o) (- res 1)
o (el-test-struct-next o)
res (mod res 16)))
res))
(defun el-test-main ()
(let* ((o1 (make-el-test-struct :fld1 1))
(o2 (make-el-test-struct :fld1 1 :next o1))
res)
(setf (el-test-struct-next o1) o2)
(let ((time (current-time)))
(setf res (el-test-inner o1 *times*))
;; show time passed
(message "%.06f" (float-time (time-since time))))
(format "%d %d" (el-test-struct-fld5 o1) res)))
Скопировать в буфер, скомпилировать «M-x byte-compile-file», в *scratch* буфере загрузить «C-x-e» для каждой формы, результаты в буфере *Messages*:
(load "~/ your path /elisp_test/test.elc")
(el-test-main)
Исходная версия tp_for_my_bunghole, :
Emacs Lisp.
~42.504390 seconds;
Интересно, производительность на уровне интерпретатора Python со __slots__ в классе, это очень хорошо.
(defvar *times*)
(setq *times* (* 100 1000 1000))
(defstruct (el-test-struct (:type vector))
next fld1 fld2 fld3 fld4 fld5)
(defun el-test-inner (o n)
(let ((res 0))
(dotimes (i n)
(incf res (el-test-struct-fld1 o))
(setf (el-test-struct-fld2 o) (el-test-struct-fld1 o)
(el-test-struct-fld3 o) (el-test-struct-fld2 o)
(el-test-struct-fld4 o) (el-test-struct-fld3 o)
(el-test-struct-fld5 o) (el-test-struct-fld4 o)
(el-test-struct-fld1 o) (- res 1)
o (el-test-struct-next o)
res (mod res 16)))
res))
(defun el-test-main ()
(let* ((o1 (make-el-test-struct :fld1 1))
(o2 (make-el-test-struct :fld1 1 :next o1))
res)
(setf (el-test-struct-next o1) o2)
(let ((time (current-time)))
(setf res (el-test-inner o1 *times*))
;; show time passed
(message "%.06f" (float-time (time-since time))))
(format "%d %d" (el-test-struct-fld5 o1) res)))
Скопировать в буфер, скомпилировать «M-x byte-compile-file», в *scratch* буфере загрузить «C-x-e» для каждой формы, результаты в буфере *Messages*:
(load "~/ your path /elisp_test/test.elc")
(el-test-main)