performance measurements

Each table row shows performance measurements for this F# Mono program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
250,0005.095.1093,200701  0% 0% 2% 100%
2,500,00060.0560.10118,284701  0% 1% 1% 100%
25,000,000741.80742.24641,736701  0% 1% 1% 100%

Read the ↓ make, command line, and program output logs to see how this program was run.

Read k-nucleotide benchmark to see what this program should do.

 notes

F# Compiler for F# 3.1 (Open Source Edition)

Mono JIT compiler version 4.1.0 (master/435cc01 Wed May 20 21:03:41 PDT 2015)
LLVM: yes(3.6.0svn-mono-master/ce4fcec)
GC: sgen

 k-nucleotide F# Mono program source code

(* The Computer Language Benchmarks Game
 * http://benchmarksgame.alioth.debian.org/
 *
 * contributed by Jimmy Tang
 *)
open System
open System.IO
open System.Collections.Generic

// make our hashtable using System.Collections.Generic.Dictionary
let maketable (dna:string) (length:int) =
   let d = new Dictionary<_,_>()
   for start in 0..(dna.Length - length) do
      let substr = dna.Substring(start, length)
      let x = ref (ref 0)
      if d.TryGetValue(substr, x) then x.Value := ! !x + 1
      else d.[substr] <- ref 1
   d

// frequency for all substrings of a given length
let frequencies (dna:string) (length:int) = [
   let d = maketable dna length
   let total = d.Values |> Seq.map (!) |> Seq.sum
   yield! [ for pair in d ->
             pair.Key.ToUpper(), (float(pair.Value.Value) * 100.0 /float(total))]
         |> List.sortBy (snd >> (~-))
         |> List.map (fun (s,c) -> sprintf "%s %.3f" s c)
   yield ""
]

// frequency of occurrence for a particular substring
let countSubstring dna (substring:string) = [
   let d = maketable dna (substring.Length)
   yield (sprintf "%d\t%s"
      (if d.ContainsKey(substring) then !d.[substring] else 0)
      (substring.ToUpper()))
]

let input = Console.In
let dna = seq { while true do yield input.ReadLine() }
        |> Seq.takeWhile (fun x -> x <> null)
        |> Seq.skipWhile (fun x -> not(x.StartsWith(">THREE")))
        |> Seq.skip 1
        |> String.concat ""

[for len in [1;2] -> async { return frequencies dna len }] @
[for str in ["ggt";"ggta";"ggtatt";"ggtattttaatt";"ggtattttaatttatagt"]
 -> async { return countSubstring dna str }]
|> List.rev
|> Async.Parallel
|> Async.RunSynchronously
|> Array.rev
|> Seq.concat
|> Seq.iter (printfn "%s")

 make, command-line, and program output logs

Thu, 21 May 2015 14:00:01 GMT

MAKE:
mv knucleotide.fsharp knucleotide.fs
/usr/local/bin/fsharpc --target:exe --platform:x86 -O  -o knucleotide.fsharp_run.exe knucleotide.fs
F# Compiler for F# 3.1 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License
rm knucleotide.fs
4.43s to complete and log all make actions

COMMAND LINE:
/usr/local/bin/mono --llvm --gc=sgen knucleotide.fsharp_run.exe 0 < knucleotide-input25000000.txt

PROGRAM OUTPUT:
A 30.295
T 30.151
C 19.800
G 19.754

AA 9.177
TA 9.132
AT 9.131
TT 9.091
CA 6.002
AC 6.001
AG 5.987
GA 5.984
CT 5.971
TC 5.971
GT 5.957
TG 5.956
CC 3.917
GC 3.911
CG 3.909
GG 3.902

1471758	GGT
446535	GGTA
47336	GGTATT
893	GGTATTTTAATT
893	GGTATTTTAATTTATAGT

Revised BSD license

  Home   Conclusions   License   Play