From: Peter K. <ps...@cs...> - 2017-04-26 23:20:57
|
Hello, I'm writing some math codes, and in sbcl 1.3.15 on linux xubuntu 16.04LTS x86_64 and I get some unexpected consing. Maybe you all can help explain what I'm doing that is causing it. I have some test cases in the REPL: ;; defined at the repl (defun test1 (arg1 arg2) (let ((a (float (cos arg1) 1.0)) (b (float (sin arg2) 1.0))) (values a b))) (defun test2 (arg1 arg2) (let ((a (cos arg1)) (b (sin arg2))) (values a b))) (defun test3 (arg1 arg2) (let ((a (float arg1 1.0)) (b (float arg2 1.0))) (values a b))) CL-USER> (time (loop repeat 1000000 do (test1 (/ pi 6) (/ pi 6)))) Evaluation took: 0.095 seconds of real time 0.093334 seconds of total run time (0.093334 user, 0.000000 system) [ Run times consist of 0.010 seconds GC time, and 0.084 seconds non-GC time. ] 97.89% CPU 285,006,444 processor cycles 32,014,336 bytes consed NIL CL-USER> (time (loop repeat 1000000 do (test2 (/ pi 6) (/ pi 6)))) Evaluation took: 0.080 seconds of real time 0.080000 seconds of total run time (0.080000 user, 0.000000 system) 100.00% CPU 239,210,455 processor cycles 31,981,568 bytes consed NIL CL-USER> (time (loop repeat 1000000 do (test3 (/ pi 6) (/ pi 6)))) Evaluation took: 0.027 seconds of real time 0.030000 seconds of total run time (0.030000 user, 0.000000 system) 111.11% CPU 82,407,547 processor cycles 0 bytes consed NIL However, and curiously, this doesn't cons: VAO> (time (loop repeat 1000000 do (funcall (lambda (arg1 arg2) (let ((a (float (sin arg1) 1.0)) (b (float (cos arg2) 1.0))) (values a b))) (/ pi 6) (/ pi 6)))) Evaluation took: 0.001 seconds of real time 0.000000 seconds of total run time (0.000000 user, 0.000000 system) 0.00% CPU 3,093,048 processor cycles 0 bytes consed NIL Any help on what I'm doing wrong and how I can remove that consing? Thank you! -pete |