[Mono-list] Mono vs Mono+LLVM

Jon Harrop jon at ffconsultancy.com
Mon Feb 1 21:19:01 EST 2010


I ran the same list-based n-queens solver written in F# on .NET, Mono 2.4/2.6, 
and Mono 2.7 with the LLVM backend and got the following results:

.NET:      2.157s
Mono 2.4:  8.933s
Mono 2.6: 10.195s
Mono 2.7: 44.367s

Note that the code generated by Mono using LLVM is running many times slower 
than the code generated using Mono's own code gen in this case.

Just for fun:

OCaml:     0.763s (standalone compiled)
OCaml:    16.649s (interpreted)
HLVM:      8.606s (JIT compiled)
HLVM:      7.972s (standalone compiled)

Here's the F# source code for this benchmark:

  let safe (x1, y1) (x2, y2) =
    x1 <> x2 && y1 <> y2 && x2 - x1 <> y2 - y1 && x1 - y2 <> x2 - y1
  
  let ps n =
    [ for i in 1 .. n do
        for j in 1 .. n do
          yield i, j ]
  
  let rec search f n qs ps accu =
    match ps with
    | [] -> if List.length qs = n then f qs accu else accu
    | q::ps ->
        search f n (q::qs) (List.filter (safe q) ps)
          (search f n qs ps accu)
  
  do
    let n = 10
    let t = System.Diagnostics.Stopwatch.StartNew()
    printfn "%d" (search (fun _ i -> i+1) n [] (ps n) 0)
    printfn "Took %gs" t.Elapsed.TotalSeconds

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e


More information about the Mono-list mailing list