SPUG: sorting hierarchical section numbers

Ivan Heffner iheffner at gmail.com
Fri Aug 11 16:09:14 PDT 2006


You could gain some efficiency by splitting before you pass you
elements of @array1 into your sort function (Hooray, Schwatzian
Transforms!).

$ benchmark -d index_sort.pm
--------------------------------------------------
outlinish_transform
--------------------------------------------------

1
1.1
1.2
1.2.1
1.2.2.1
1.3
1.3.1
1.3.2
1.3.2.1
1.4

--------------------------------------------------
straight_outlinish
--------------------------------------------------

1
1.1
1.2
1.2.1
1.2.2.1
1.3
1.3.1
1.3.2
1.3.2.1
1.4

$ benchmark index_sort.pm 50000
Benchmark: timing 50000 iterations of outlinish_transform, straight_outlinish...
outlinish_transform:  6 wallclock secs ( 5.95 usr +  0.00 sys =  5.95
CPU) @ 8403.36/s (n=50000)
straight_outlinish: 11 wallclock secs (10.17 usr +  0.00 sys = 10.17
CPU) @ 4916.42/s (n=50000)

( get the benchmark code here: http://www.whitepages.com/perl )

I hope the list keeps my attached .pm file.  If not, I'll post it separately.

-- 
Ivan Heffner
Sr. Software Engineer
DAS Lead
WhitePages.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: index_sort.pm
Type: application/octet-stream
Size: 842 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/spug-list/attachments/20060811/577438f3/attachment.obj 


More information about the spug-list mailing list