3 hours ago · Tech · 0 comments

I saw that there was some argument over how much slower slot access is than struct access, so I just decided to measure it naively. I made a two slot sruct and a CLOS version of a CONS cell with car and cdr slots and I ran LTAK using regular lists, `lists' made from CLOS conses, and `lists' made from structs. Here are the results: D:\repositories\clos-benchmark>sbcl --script run-benchmarks.lisp Benchmark: ltak over native cons cells, CLOS my-cons nodes, and my-cons-struct nodes Inputs: x=15 y=9 z=4 repeats=35 Scenario min-ms mean-ms max-ms ratio -------------------------------------------------------------------- native standard 0.129 0.146 0.186 clos standard 1.346 1.365 1.475 9.37x struct standard 0.172 0.175 0.179 1.20x native optimized 0.068 0.069 0.073 clos optimized 0.411 0.414 0.419 6.04x struct optimized 0.068 0.069 0.073 1.01x In this naive use case, structs are same as native cons cells, but CLOS objects are one ninth the speed of a struct or cons cell if you just use it…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.