performance measurements

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

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
50,0000.870.864,304652  26% 76% 2% 2%
500,0008.598.5041,148652  59% 1% 42% 1%
5,000,00085.8384.90462,776652  5% 1% 43% 54%

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

Read regex-dna benchmark to see what this program should do.

 notes

go version go1.3 linux/amd64

 regex-dna Go #7 program source code

/* The Computer Language Benchmarks Game
 * http://benchmarksgame.alioth.debian.org/
 *
 * contributed by The Go Authors.
 * modified by Glenn Brown.
 */

package main

import (
   "fmt"
   "github.com/glenn-brown/golang-pkg-pcre/src/pkg/pcre"
   "io/ioutil"
   "os"
)

var variants = []string{
   "agggtaaa|tttaccct",
   "[cgt]gggtaaa|tttaccc[acg]",
   "a[act]ggtaaa|tttacc[agt]t",
   "ag[act]gtaaa|tttac[agt]ct",
   "agg[act]taaa|ttta[agt]cct",
   "aggg[acg]aaa|ttt[cgt]ccct",
   "agggt[cgt]aa|tt[acg]accct",
   "agggta[cgt]a|t[acg]taccct",
   "agggtaa[cgt]|[acg]ttaccct",
}

type Subst struct {
   pat, repl string
}

var substs = []Subst{
   Subst{"B", "(c|g|t)"},
   Subst{"D", "(a|g|t)"},
   Subst{"H", "(a|c|t)"},
   Subst{"K", "(g|t)"},
   Subst{"M", "(a|c)"},
   Subst{"N", "(a|c|g|t)"},
   Subst{"R", "(a|g)"},
   Subst{"S", "(c|g)"},
   Subst{"V", "(a|c|g)"},
   Subst{"W", "(a|t)"},
   Subst{"Y", "(c|t)"},
}

func countMatches(pat string, bytes []byte) int {
   re := pcre.MustCompile(pat, 0)
   n := 0
   for {
      e := re.FindIndex(bytes, 0)
      if len(e) == 0 {
         break
      }
      n++
      bytes = bytes[e[1]:]
   }
   return n
}

func main() {
   bytes, err := ioutil.ReadAll(os.Stdin)
   if err != nil {
      fmt.Fprintf(os.Stderr, "can't read input: %s\n", err)
      os.Exit(2)
   }
   ilen := len(bytes)
   // Delete the comment lines and newlines
   bytes = pcre.MustCompile("(>[^\n]+)?\n", 0).
      ReplaceAll(bytes, []byte{}, 0)
   clen := len(bytes)
   for _, s := range variants {
      fmt.Printf("%s %d\n", s, countMatches(s, bytes))
   }
   for _, sub := range substs {
      bytes = pcre.MustCompile(sub.pat, 0).
         ReplaceAll(bytes, []byte(sub.repl), 0)
   }
   fmt.Printf("\n%d\n%d\n%d\n", ilen, clen, len(bytes))
}

 make, command-line, and program output logs

Thu, 19 Jun 2014 06:32:32 GMT

MAKE:
/usr/local/src/go/bin/go build -o regexdna.go-7.go_run
0.66s to complete and log all make actions

COMMAND LINE:
./regexdna.go-7.go_run 0 < regexdna-input5000000.txt

PROGRAM OUTPUT:
agggtaaa|tttaccct 356
[cgt]gggtaaa|tttaccc[acg] 1250
a[act]ggtaaa|tttacc[agt]t 4252
ag[act]gtaaa|tttac[agt]ct 2894
agg[act]taaa|ttta[agt]cct 5435
aggg[acg]aaa|ttt[cgt]ccct 1537
agggt[cgt]aa|tt[acg]accct 1431
agggta[cgt]a|t[acg]taccct 1608
agggtaa[cgt]|[acg]ttaccct 2178

50833411
50000000
66800214

Revised BSD license

  Home   Conclusions   License   Play