Skip to content
Tcl Source Code Artifact [4f048532ae]
Login

Artifact [4f048532ae]

Artifact 4f048532aede1b91ad42948895324e572196babf:

Ticket change [4f048532ae] - Ticket [b43f2b49f75ec8b6|b43f2b49f7] <i>Non-linear lappend performance</i> status still Open with 4 other changes by dkf on 2014-07-15 22:21:18.
D 2014-07-15T22:21:18.609
J icomment By\slinear,\sI\smean\sthat\sthe\soverall\stime\sshould\sbe\slinear\sin\sthe\snumber\sof\sitems,\si.e.\sO(1)\s<tt>lappend</tt>.\sWhat\swe've\sgot\sisn't.\r\n<p>\r\nUsing\sthe\sActiveTcl\sdistro\sof\s8.6.1\s(not\sto\spick\son\sthem,\sbut\sit's\scommon\sin\sthe\swild)\sI\ssee:\r\n<pre>\r\n%\stime\s{apply\s{x\s{for\s{set\si\s0}\s{$i<$x}\s{incr\si}\s{lappend\sl\sx}}}\s1000}\s1000\r\n67.750023\smicroseconds\sper\siteration\r\n%\stime\s{apply\s{x\s{for\s{set\si\s0}\s{$i<$x}\s{incr\si}\s{lappend\sl\sx}}}\s3000}\s1000\r\n188.477614\smicroseconds\sper\siteration\r\n%\stime\s{apply\s{x\s{for\s{set\si\s0}\s{$i<$x}\s{incr\si}\s{lappend\sl\sx\sy\sz}}}\s1000}\s1000\r\n3220.6352030000003\smicroseconds\sper\siteration\r\n%\stime\s{apply\s{x\s{for\s{set\si\s0}\s{$i<$x}\s{incr\si}\s{lappend\sl\sx}}}\s50000}\s1000\r\n3301.317531\smicroseconds\sper\siteration\r\n%\stime\s{apply\s{x\s{for\s{set\si\s0}\s{$i<$x}\s{incr\si}\s{lappend\sl\sx\sy}}}\s1500}\s1000\r\n5049.768402\smicroseconds\sper\siteration\r\n</pre>\r\nIn\sshort,\sthe\stime\sto\sassemble\sa\s3k-element\slist,\s3\selements\sat\sa\stime,\sis\smore\sthan\s15\stimes\sslower\sthan\sdoing\sit\sby\sindividual\selements,\sand\sis\sin\sfact\ssimilar\sto\sassembling\sa\s50k-element\slist\sby\ssingle\s<tt>lappend</tt>s.\s(Something\sis\sdefinitely\sgoing\swrong,\sespecially\sas\sthe\sproblem\sgets\sworse\swith\slonger\slists;\ssee\sthe\slast\stiming\srun,\swhich\sis\salso\sassembling\sa\s3k-element\slist.)\r\n<p>\r\nThe\sreal\s"customer"\scode,\sshown\sto\sme\sat\sEuroTcl\sby\sAlexandru\sDadalau\s(and\swhich\sI\scan't\sreproduce\shere\sas\sit\swas\stied\sto\sa\scomplex\sproduct),\shad\smuch\slarger\slists;\sit\swas\sof\sa\sscript\sthat\swas\sprocessing\sa\s3D\sgeometry\sfile\sso\sthat\s<i>in\ssilico</i>\sengineering\ssimulations\scould\sbe\srun\son\sthe\stool\sparts\sdescribed.\s(I\sthink.)\sIt\swas\staking\sover\s20\sminutes\sto\sload\sa\snetlist\swhen\susing\sa\smulti-value\s,\sand\she\shad\s"optimized"\sit\sby\susing\sa\schunk\sof\shorrible\s<tt>append</tt>-based\sstring\scode\sinstead\s(taking\sthe\sprocessing\stime\sto\saround\sa\sminute\son\sthe\ssame\sinput).\sSwitching\sto\susing\ssingle-value\s<tt>lappend</tt>s\saccelerated\sthe\scode\sto\swhere\sit\stook\s5-10\sseconds…\r\n<p>\r\nThe\slack\sof\saccess\sto\sthe\soriginal\scode\sshouldn't\smatter.\sThe\stiming\sruns\sabove\sreproduce\sthe\sproblem\sperfectly\sadequately.\s(My\scurrent\snear-trunk\sbuilds\saren't\ssuitable\sfor\stiming\sproblem\shunting;\sthey've\sgot\sfull\sdebugging\senabled\sand\sso\stake\saround\s100\stimes\slonger\sanyway.)
J login dkf
J mimetype text/html
J username dkf
K b43f2b49f75ec8b60c7e5b59a21556528657e77a
U dkf
Z e23e99e157a23a0e8ca7db3c85da519a