Browse thread
[Caml-list] @, List.append, and tail recursion
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Olivier Andrieu <oandrieu@n...> |
| Subject: | Re: [Caml-list] @, List.append, and tail recursion |
Brian Hurt [Thursday 30 January 2003] : > For short lists, this is the worst performer overall. I whipped up a > quick microbenchmark to compare the various implementations- the three > implementations are included in this email. The three programs are: > > list1.ml: lappend uses the @ operator to append the list > > list2.ml: uses local rev_append and rev functions (similiar to those in > List) to append the list > > list3.ml: uses Olivier's set_cdr function. > > The results I saw (compiling with ocamlopt -o list list.ml on a 1.4GHz P4 > running Linux and ocaml 3.06) are: > > list1: 1.462s > list2: 1.757s > list3: 1.824s There's an assert in setcdr : it's important because the first argument mustn't be an empty list. It's never the case here, so you can safely compile with -noassert. On my hardware list3 seems to be a teeny bit faster than list1 but anyway, since list2 is just barely slower, I'm not sure it's worth the trouble. -- Olivier ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners