List Operations
List operations test. The following describes the behaviour of every program:
- Create a list (L1) of integers from 1 through SIZE.
- Copy L1 to L2 (can use any builtin list copy function, if available)
- Remove each individual item from the left side (head) of L2 and append it to the right side (tail) of L3 (preserving order). (L2 should be emptied by one item at a time as that item is appended to L3).
- Remove each individual item from the right side (tail) of L3 and append it to the right side (tail) of L2 (reversing list). (L3 should be emptied by one item at a time as that item is appended to L2).
- Reverse L1 (preferably in place) (can use any builtin function for this, if available).
- Check that first item of L1 is now == SIZE, and compare L1 and L2 for equality and return length of L1 (which should be equal to SIZE).
Test Goal
This quite contrived test attempts to execise different list operations, like append, pop, copy, reverse in place. There is no by index access, so languages with lists internally implemented as arrays should not perform better, but probably worse due to the presence of pop from left operations. Languages implementing many basic list operations as built-ins may have some significant advantage.
Input argument meaning
In this test the argument specify the list length (called SIZE in the test's description).
Results
Language | Milliseconds | Weighted Characters |
---|---|---|
gcc 2.95.4 | 13 | 5896 |
Perl 5.8.0 | 264 | 1218 |
gcj 3.3.2 | 266 | 1713 |
Ruby 1.7.2 | 296 | 923 |
MzScheme 203 | 368 | 1450 |
Python 2.3.2 | 453 | 654 |
Tcl 8.4.5 | 994 | 1580 |
Last updated: Sun Jan 18 11:15:31 CET 2004