Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

*** empty log message ***

  • Loading branch information...
commit e8de418422a022af0018af0611cf31cf7cf488c6 1 parent b2046b9
igouy-guest authored
View
77 bench/regexdna/regexdna.go-5.go
@@ -0,0 +1,77 @@
+/* The Computer Language Benchmarks Game
+ * http://shootout.alioth.debian.org/
+ *
+ * contributed by The Go Authors.
+ */
+
+package main
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+ "regexp"
+)
+
+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 := regexp.MustCompile(pat)
+ n := 0
+ for {
+ e := re.FindIndex(bytes)
+ 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 = regexp.MustCompile("(>[^\n]+)?\n").ReplaceAll(bytes, []byte{})
+ clen := len(bytes)
+ for _, s := range variants {
+ fmt.Printf("%s %d\n", s, countMatches(s, bytes))
+ }
+ for _, sub := range substs {
+ bytes = regexp.MustCompile(sub.pat).ReplaceAll(bytes, []byte(sub.repl))
+ }
+ fmt.Printf("\n%d\n%d\n%d\n", ilen, clen, len(bytes))
+}
View
95 bench/regexdna/regexdna.go-6.go
@@ -0,0 +1,95 @@
+/* The Computer Language Benchmarks Game
+ * http://shootout.alioth.debian.org/
+ *
+ * contributed by The Go Authors.
+ */
+
+package main
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+ "runtime"
+ "regexp"
+)
+
+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 := regexp.MustCompile(pat)
+ n := 0
+ for {
+ e := re.FindIndex(bytes)
+ if e == nil {
+ break
+ }
+ n++
+ bytes = bytes[e[1]:]
+ }
+ return n
+}
+
+func main() {
+ runtime.GOMAXPROCS(4)
+ 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 = regexp.MustCompile("(>[^\n]+)?\n").ReplaceAll(bytes, []byte{})
+ clen := len(bytes)
+
+ mresults := make([]chan int, len(variants))
+ for i, s := range variants {
+ ch := make(chan int)
+ mresults[i] = ch
+ go func(ss string) {
+ ch <- countMatches(ss, bytes)
+ }(s)
+ }
+
+ lenresult := make(chan int)
+ bb := bytes
+ go func() {
+ for _, sub := range substs {
+ bb = regexp.MustCompile(sub.pat).ReplaceAll(bb, []byte(sub.repl))
+ }
+ lenresult <- len(bb)
+ }()
+
+ for i, s := range variants {
+ fmt.Printf("%s %d\n", s, <-mresults[i])
+ }
+ fmt.Printf("\n%d\n%d\n%d\n", ilen, clen, <-lenresult)
+}
View
52 bencher/README
@@ -1,7 +1,7 @@
# The Computer Language Benchmarks Game
-# $Id: README,v 1.4 2010-03-09 20:36:45 igouy-guest Exp $
+# $Id: README,v 1.5 2011-04-19 21:18:43 igouy-guest Exp $
- bencher - The Computer Language Benchmarks Game - March 2010
+ bencher - The Computer Language Benchmarks Game - April 2011
@@ -20,7 +20,7 @@
- LAZY, STUBBORN, QUIET
+ LAZY, STUBBORN, NOT MAGIC, QUIET
bencher only measures when there is no dat file to match every
program source code file, or when the dat file is older than
@@ -31,6 +31,10 @@
is not available; bencher will give a basic size for source code
when highlight is not available.
+ bencher doesn't do magic - bencher uses the makefiles/my.*.ini
+ settings - so YOU must configure makefiles/my.*.ini to match where
+ things are on your computer.
+
bencher usually writes good news to the console; for the bad news
look through bencher/tmp/bencher.log
@@ -45,7 +49,8 @@
Python Win32 Extensions (for win32 process monitoring)
see http://sourceforge.net/projects/pywin32/
- (add \Python26 to the system path)
+ (add your Python directory to the system path,
+ for example \Python26 )
RECOMMENDATIONS
@@ -93,12 +98,30 @@
[ python bin\bencher.py --conf makefiles\my.win32.ini ]
measure cpu & elapsed time & memory & cpu load
+ Tue 14:00:41 .PROGRAM FAILED nbody.python [4]
+ Tue 14:00:41 .PROGRAM FAILED nbody.compiledpython [3]
+ Tue 14:00:42 .PROGRAM FAILED regexdna.python [2]
+ Tue 14:00:42 .PROGRAM FAILED regexdna.compiledpython [1]
+
+ All the test programs have FAILED - probably the location of
+ the Python interpreter on your computer is different than
+ the location given in makefiles/my.*.ini
+
+ Make sure that PYTHON in the [tools] section of makefiles/my.*.ini
+ is set to the location of the Python interpreter on your computer.
+
+
+ 4) python bin/bencher.py --conf makefiles/my.linux.ini
+
+ [ python bin\bencher.py --conf makefiles\my.win32.ini ]
+
+ measure cpu & elapsed time & memory & cpu load
Sat 18:06:02 .....OK nbody.python [4]
Sat 18:06:06 .MAKE ERROR nbody.compiledpython [3]
Sat 18:06:06 .OK regexdna.python [2]
Sat 18:06:06 .MAKE ERROR regexdna.compiledpython [1]
- 4) look through tmp/bencher.log
+ 5) look through tmp/bencher.log
[ look through tmp\bencher.log ]
@@ -124,7 +147,7 @@
2010-03-06 18:06:06,259 INFO copy *.csv files to c:\bencher\summary
2010-03-06 18:06:06,259 INFO copy *.log files to c:\bencher\run_logs
- 5) look through summary/measurements.csv
+ 6) look through summary/measurements.csv
[ look through summary\measurements.csv ]
@@ -140,7 +163,7 @@
INSTALL GNU MAKE AND DO_OVER
- 3) python bin/bencher.py --conf makefiles/my.linux.ini compiledpython
+ 7) python bin/bencher.py --conf makefiles/my.linux.ini compiledpython
[ python bin\bencher.py --conf makefiles\my.win32.ini compiledpython ]
@@ -149,7 +172,7 @@
Sat 18:11:53 .OK regexdna.compiledpython [1]
- 4) look through tmp/bencher.log
+ 8) look through tmp/bencher.log
[ look through tmp\bencher.log ]
@@ -166,7 +189,7 @@
2010-03-06 18:11:53,532 INFO copy *.log files to c:\bencher\run_logs
- 5) look through summary/measurements.csv
+ 9) look through summary/measurements.csv
[ look through summary\measurements.csv ]
@@ -188,7 +211,7 @@
LINUX FORCE DO-OVER [ WIN32 FORCE DO-OVER ]
- 3) python bin/bencher.py --conf makefiles/my.linux.ini python compiledpython
+ 10) python bin/bencher.py --conf makefiles/my.linux.ini python compiledpython
[ python bin\bencher.py --conf makefiles\my.win32.ini python compiledpython ]
@@ -201,7 +224,7 @@
LINUX FORCE DO-OVER AGAIN [ WIN32 FORCE DO-OVER AGAIN ]
- 3) python bin/bencher.py --conf makefiles/my.linux.ini python regexdna
+ 11) python bin/bencher.py --conf makefiles/my.linux.ini python regexdna
[ python bin\bencher.py --conf makefiles\my.win32.ini python regexdna ]
@@ -213,7 +236,7 @@
AND AGAIN [ AND AGAIN ]
- 3) python bin/bencher.py --conf makefiles/my.linux.ini nbody python
+ 12) python bin/bencher.py --conf makefiles/my.linux.ini nbody python
[ python bin\bencher.py --conf makefiles\my.win32.ini nbody python ]
@@ -225,7 +248,7 @@
OTHERWISE [ OTHERWISE ]
- 3) python bin/bencher.py --conf makefiles/my.linux.ini
+ 13) python bin/bencher.py --conf makefiles/my.linux.ini
[ python bin\bencher.py --conf makefiles\my.win32.ini ]
@@ -236,7 +259,8 @@
QUICK FIXES
- Check PYTHON in the [tools] section of makefiles/my.*.ini is correct
+ Check that the [tools] section of makefiles/my.*.ini settings match
+ the location of those interpreters and compilers on your computer.
To force measurement of just one program, delete the corresponding dat file
and re-measure.
View
4 bencher/bin/bencher.py
@@ -1,5 +1,5 @@
# The Computer Language Benchmarks Game
-# $Id: bencher.py,v 1.6 2010-03-10 22:32:21 igouy-guest Exp $
+# $Id: bencher.py,v 1.7 2011-04-19 21:18:54 igouy-guest Exp $
"""
Description: bencher does repeated measurements of program
@@ -1338,7 +1338,7 @@ def force(items):
def main():
- print 'bencher release 0.7'
+ print 'bencher release 0.8'
try:
options,remeasure = getopt(sys.argv[1:],'',['conf='])
View
52 bencher/readme.txt
@@ -1,7 +1,7 @@
# The Computer Language Benchmarks Game
-# $Id: readme.txt,v 1.3 2010-03-09 20:36:46 igouy-guest Exp $
+# $Id: readme.txt,v 1.4 2011-04-19 21:18:51 igouy-guest Exp $
- bencher - The Computer Language Benchmarks Game - March 2010
+ bencher - The Computer Language Benchmarks Game - April 2011
@@ -20,7 +20,7 @@
- LAZY, STUBBORN, QUIET
+ LAZY, STUBBORN, NOT MAGIC, QUIET
bencher only measures when there is no dat file to match every
program source code file, or when the dat file is older than
@@ -31,6 +31,10 @@
is not available; bencher will give a basic size for source code
when highlight is not available.
+ bencher doesn't do magic - bencher uses the makefiles/my.*.ini
+ settings - so YOU must configure makefiles/my.*.ini to match where
+ things are on your computer.
+
bencher usually writes good news to the console; for the bad news
look through bencher/tmp/bencher.log
@@ -45,7 +49,8 @@
Python Win32 Extensions (for win32 process monitoring)
see http://sourceforge.net/projects/pywin32/
- (add \Python26 to the system path)
+ (add your Python directory to the system path,
+ for example \Python26 )
RECOMMENDATIONS
@@ -93,12 +98,30 @@
[ python bin\bencher.py --conf makefiles\my.win32.ini ]
measure cpu & elapsed time & memory & cpu load
+ Tue 14:00:41 .PROGRAM FAILED nbody.python [4]
+ Tue 14:00:41 .PROGRAM FAILED nbody.compiledpython [3]
+ Tue 14:00:42 .PROGRAM FAILED regexdna.python [2]
+ Tue 14:00:42 .PROGRAM FAILED regexdna.compiledpython [1]
+
+ All the test programs have FAILED - probably the location of
+ the Python interpreter on your computer is different than
+ the location given in makefiles/my.*.ini
+
+ Make sure that PYTHON in the [tools] section of makefiles/my.*.ini
+ is set to the location of the Python interpreter on your computer.
+
+
+ 4) python bin/bencher.py --conf makefiles/my.linux.ini
+
+ [ python bin\bencher.py --conf makefiles\my.win32.ini ]
+
+ measure cpu & elapsed time & memory & cpu load
Sat 18:06:02 .....OK nbody.python [4]
Sat 18:06:06 .MAKE ERROR nbody.compiledpython [3]
Sat 18:06:06 .OK regexdna.python [2]
Sat 18:06:06 .MAKE ERROR regexdna.compiledpython [1]
- 4) look through tmp/bencher.log
+ 5) look through tmp/bencher.log
[ look through tmp\bencher.log ]
@@ -124,7 +147,7 @@
2010-03-06 18:06:06,259 INFO copy *.csv files to c:\bencher\summary
2010-03-06 18:06:06,259 INFO copy *.log files to c:\bencher\run_logs
- 5) look through summary/measurements.csv
+ 6) look through summary/measurements.csv
[ look through summary\measurements.csv ]
@@ -140,7 +163,7 @@
INSTALL GNU MAKE AND DO_OVER
- 3) python bin/bencher.py --conf makefiles/my.linux.ini compiledpython
+ 7) python bin/bencher.py --conf makefiles/my.linux.ini compiledpython
[ python bin\bencher.py --conf makefiles\my.win32.ini compiledpython ]
@@ -149,7 +172,7 @@
Sat 18:11:53 .OK regexdna.compiledpython [1]
- 4) look through tmp/bencher.log
+ 8) look through tmp/bencher.log
[ look through tmp\bencher.log ]
@@ -166,7 +189,7 @@
2010-03-06 18:11:53,532 INFO copy *.log files to c:\bencher\run_logs
- 5) look through summary/measurements.csv
+ 9) look through summary/measurements.csv
[ look through summary\measurements.csv ]
@@ -188,7 +211,7 @@
LINUX FORCE DO-OVER [ WIN32 FORCE DO-OVER ]
- 3) python bin/bencher.py --conf makefiles/my.linux.ini python compiledpython
+ 10) python bin/bencher.py --conf makefiles/my.linux.ini python compiledpython
[ python bin\bencher.py --conf makefiles\my.win32.ini python compiledpython ]
@@ -201,7 +224,7 @@
LINUX FORCE DO-OVER AGAIN [ WIN32 FORCE DO-OVER AGAIN ]
- 3) python bin/bencher.py --conf makefiles/my.linux.ini python regexdna
+ 11) python bin/bencher.py --conf makefiles/my.linux.ini python regexdna
[ python bin\bencher.py --conf makefiles\my.win32.ini python regexdna ]
@@ -213,7 +236,7 @@
AND AGAIN [ AND AGAIN ]
- 3) python bin/bencher.py --conf makefiles/my.linux.ini nbody python
+ 12) python bin/bencher.py --conf makefiles/my.linux.ini nbody python
[ python bin\bencher.py --conf makefiles\my.win32.ini nbody python ]
@@ -225,7 +248,7 @@
OTHERWISE [ OTHERWISE ]
- 3) python bin/bencher.py --conf makefiles/my.linux.ini
+ 13) python bin/bencher.py --conf makefiles/my.linux.ini
[ python bin\bencher.py --conf makefiles\my.win32.ini ]
@@ -236,7 +259,8 @@
QUICK FIXES
- Check PYTHON in the [tools] section of makefiles/my.*.ini is correct
+ Check that the [tools] section of makefiles/my.*.ini settings match
+ the location of those interpreters and compilers on your computer.
To force measurement of just one program, delete the corresponding dat file
and re-measure.
View
BIN  website/websites/download/bencher.zip
Binary file not shown
View
95 website/websites/u64/code/regexdna.6.go.code
@@ -0,0 +1,95 @@
+<span class="hl com">/* The Computer Language Benchmarks Game</span>
+<span class="hl com"> * http://shootout.alioth.debian.org/</span>
+<span class="hl com"> *</span>
+<span class="hl com"> * contributed by The Go Authors.</span>
+<span class="hl com"> */</span>
+
+<span class="hl kwa">package</span> main
+
+<span class="hl kwa">import</span> <span class="hl sym">(</span>
+ <span class="hl str">&quot;fmt&quot;</span>
+ <span class="hl str">&quot;io/ioutil&quot;</span>
+ <span class="hl str">&quot;os&quot;</span>
+ <span class="hl str">&quot;runtime&quot;</span>
+ <span class="hl str">&quot;regexp&quot;</span>
+<span class="hl sym">)</span>
+
+<span class="hl kwa">var</span> variants <span class="hl sym">= []</span>string<span class="hl sym">{</span>
+ <span class="hl str">&quot;agggtaaa|tttaccct&quot;</span><span class="hl sym">,</span>
+ <span class="hl str">&quot;[cgt]gggtaaa|tttaccc[acg]&quot;</span><span class="hl sym">,</span>
+ <span class="hl str">&quot;a[act]ggtaaa|tttacc[agt]t&quot;</span><span class="hl sym">,</span>
+ <span class="hl str">&quot;ag[act]gtaaa|tttac[agt]ct&quot;</span><span class="hl sym">,</span>
+ <span class="hl str">&quot;agg[act]taaa|ttta[agt]cct&quot;</span><span class="hl sym">,</span>
+ <span class="hl str">&quot;aggg[acg]aaa|ttt[cgt]ccct&quot;</span><span class="hl sym">,</span>
+ <span class="hl str">&quot;agggt[cgt]aa|tt[acg]accct&quot;</span><span class="hl sym">,</span>
+ <span class="hl str">&quot;agggta[cgt]a|t[acg]taccct&quot;</span><span class="hl sym">,</span>
+ <span class="hl str">&quot;agggtaa[cgt]|[acg]ttaccct&quot;</span><span class="hl sym">,</span>
+<span class="hl sym">}</span>
+
+<span class="hl kwa">type</span> Subst <span class="hl kwa">struct</span> <span class="hl sym">{</span>
+ pat<span class="hl sym">,</span> repl string
+<span class="hl sym">}</span>
+
+<span class="hl kwa">var</span> substs <span class="hl sym">= []</span>Subst<span class="hl sym">{</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;B&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(c|g|t)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;D&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(a|g|t)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;H&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(a|c|t)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;K&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(g|t)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;M&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(a|c)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;N&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(a|c|g|t)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;R&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(a|g)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;S&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(c|g)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;V&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(a|c|g)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;W&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(a|t)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;Y&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(c|t)&quot;</span><span class="hl sym">},</span>
+<span class="hl sym">}</span>
+
+<span class="hl kwa">func</span> countMatches<span class="hl sym">(</span>pat string<span class="hl sym">,</span> bytes <span class="hl sym">[]</span>byte<span class="hl sym">)</span> int <span class="hl sym">{</span>
+ re <span class="hl sym">:=</span> regexp<span class="hl sym">.</span>MustCompile<span class="hl sym">(</span>pat<span class="hl sym">)</span>
+ n <span class="hl sym">:=</span> <span class="hl num">0</span>
+ <span class="hl kwa">for</span> <span class="hl sym">{</span>
+ e <span class="hl sym">:=</span> re<span class="hl sym">.</span>FindIndex<span class="hl sym">(</span>bytes<span class="hl sym">)</span>
+ <span class="hl kwa">if</span> e <span class="hl sym">==</span> nil <span class="hl sym">{</span>
+ <span class="hl kwa">break</span>
+ <span class="hl sym">}</span>
+ n<span class="hl sym">++</span>
+ bytes <span class="hl sym">=</span> bytes<span class="hl sym">[</span>e<span class="hl sym">[</span><span class="hl num">1</span><span class="hl sym">]:]</span>
+ <span class="hl sym">}</span>
+ <span class="hl kwa">return</span> n
+<span class="hl sym">}</span>
+
+<span class="hl kwa">func</span> main<span class="hl sym">() {</span>
+ runtime<span class="hl sym">.</span>GOMAXPROCS<span class="hl sym">(</span><span class="hl num">4</span><span class="hl sym">)</span>
+ bytes<span class="hl sym">,</span> err <span class="hl sym">:=</span> ioutil<span class="hl sym">.</span>ReadAll<span class="hl sym">(</span>os<span class="hl sym">.</span>Stdin<span class="hl sym">)</span>
+ <span class="hl kwa">if</span> err <span class="hl sym">!=</span> nil <span class="hl sym">{</span>
+ fmt<span class="hl sym">.</span>Fprintf<span class="hl sym">(</span>os<span class="hl sym">.</span>Stderr<span class="hl sym">,</span> <span class="hl str">&quot;can't read input: %s</span><span class="hl esc">\n</span><span class="hl str">&quot;</span><span class="hl sym">,</span> err<span class="hl sym">)</span>
+ os<span class="hl sym">.</span>Exit<span class="hl sym">(</span><span class="hl num">2</span><span class="hl sym">)</span>
+ <span class="hl sym">}</span>
+ ilen <span class="hl sym">:=</span> len<span class="hl sym">(</span>bytes<span class="hl sym">)</span>
+ <span class="hl slc">// Delete the comment lines and newlines</span>
+ bytes <span class="hl sym">=</span> regexp<span class="hl sym">.</span>MustCompile<span class="hl sym">(</span><span class="hl str">&quot;(&gt;[^</span><span class="hl esc">\n</span><span class="hl str">]+)?</span><span class="hl esc">\n</span><span class="hl str">&quot;</span><span class="hl sym">).</span>ReplaceAll<span class="hl sym">(</span>bytes<span class="hl sym">, []</span>byte<span class="hl sym">{})</span>
+ clen <span class="hl sym">:=</span> len<span class="hl sym">(</span>bytes<span class="hl sym">)</span>
+
+ mresults <span class="hl sym">:=</span> make<span class="hl sym">([]</span><span class="hl kwa">chan</span> int<span class="hl sym">,</span> len<span class="hl sym">(</span>variants<span class="hl sym">))</span>
+ <span class="hl kwa">for</span> i<span class="hl sym">,</span> s <span class="hl sym">:=</span> <span class="hl kwa">range</span> variants <span class="hl sym">{</span>
+ ch <span class="hl sym">:=</span> make<span class="hl sym">(</span><span class="hl kwa">chan</span> int<span class="hl sym">)</span>
+ mresults<span class="hl sym">[</span>i<span class="hl sym">] =</span> ch
+ <span class="hl kwa">go func</span><span class="hl sym">(</span>ss string<span class="hl sym">) {</span>
+ ch <span class="hl sym">&lt;-</span> countMatches<span class="hl sym">(</span>ss<span class="hl sym">,</span> bytes<span class="hl sym">)</span>
+ <span class="hl sym">}(</span>s<span class="hl sym">)</span>
+ <span class="hl sym">}</span>
+
+ lenresult <span class="hl sym">:=</span> make<span class="hl sym">(</span><span class="hl kwa">chan</span> int<span class="hl sym">)</span>
+ bb <span class="hl sym">:=</span> bytes
+ <span class="hl kwa">go func</span><span class="hl sym">() {</span>
+ <span class="hl kwa">for</span> _<span class="hl sym">,</span> sub <span class="hl sym">:=</span> <span class="hl kwa">range</span> substs <span class="hl sym">{</span>
+ bb <span class="hl sym">=</span> regexp<span class="hl sym">.</span>MustCompile<span class="hl sym">(</span>sub<span class="hl sym">.</span>pat<span class="hl sym">).</span>ReplaceAll<span class="hl sym">(</span>bb<span class="hl sym">, []</span>byte<span class="hl sym">(</span>sub<span class="hl sym">.</span>repl<span class="hl sym">))</span>
+ <span class="hl sym">}</span>
+ lenresult <span class="hl sym">&lt;-</span> len<span class="hl sym">(</span>bb<span class="hl sym">)</span>
+ <span class="hl sym">}()</span>
+
+ <span class="hl kwa">for</span> i<span class="hl sym">,</span> s <span class="hl sym">:=</span> <span class="hl kwa">range</span> variants <span class="hl sym">{</span>
+ fmt<span class="hl sym">.</span>Printf<span class="hl sym">(</span><span class="hl str">&quot;%s %d</span><span class="hl esc">\n</span><span class="hl str">&quot;</span><span class="hl sym">,</span> s<span class="hl sym">, &lt;-</span>mresults<span class="hl sym">[</span>i<span class="hl sym">])</span>
+ <span class="hl sym">}</span>
+ fmt<span class="hl sym">.</span>Printf<span class="hl sym">(</span><span class="hl str">&quot;</span><span class="hl esc">\n</span><span class="hl str">%d</span><span class="hl esc">\n</span><span class="hl str">%d</span><span class="hl esc">\n</span><span class="hl str">%d</span><span class="hl esc">\n</span><span class="hl str">&quot;</span><span class="hl sym">,</span> ilen<span class="hl sym">,</span> clen<span class="hl sym">, &lt;-</span>lenresult<span class="hl sym">)</span>
+<span class="hl sym">}</span>
View
25 website/websites/u64/code/regexdna.6.go.log
@@ -0,0 +1,25 @@
+
+Sat, 16 Apr 2011 23:40:53 GMT
+
+MAKE:
+/usr/local/src/go/bin/6g -B -o regexdna.go-6.go.6 regexdna.go-6.go && \
+ /usr/local/src/go/bin/6l -o regexdna.go-6.go_run regexdna.go-6.go.6
+0.21s to complete and log all make actions
+
+COMMAND LINE:
+./regexdna.go-6.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
View
95 website/websites/u64q/code/regexdna.6.go.code
@@ -0,0 +1,95 @@
+<span class="hl com">/* The Computer Language Benchmarks Game</span>
+<span class="hl com"> * http://shootout.alioth.debian.org/</span>
+<span class="hl com"> *</span>
+<span class="hl com"> * contributed by The Go Authors.</span>
+<span class="hl com"> */</span>
+
+<span class="hl kwa">package</span> main
+
+<span class="hl kwa">import</span> <span class="hl sym">(</span>
+ <span class="hl str">&quot;fmt&quot;</span>
+ <span class="hl str">&quot;io/ioutil&quot;</span>
+ <span class="hl str">&quot;os&quot;</span>
+ <span class="hl str">&quot;runtime&quot;</span>
+ <span class="hl str">&quot;regexp&quot;</span>
+<span class="hl sym">)</span>
+
+<span class="hl kwa">var</span> variants <span class="hl sym">= []</span>string<span class="hl sym">{</span>
+ <span class="hl str">&quot;agggtaaa|tttaccct&quot;</span><span class="hl sym">,</span>
+ <span class="hl str">&quot;[cgt]gggtaaa|tttaccc[acg]&quot;</span><span class="hl sym">,</span>
+ <span class="hl str">&quot;a[act]ggtaaa|tttacc[agt]t&quot;</span><span class="hl sym">,</span>
+ <span class="hl str">&quot;ag[act]gtaaa|tttac[agt]ct&quot;</span><span class="hl sym">,</span>
+ <span class="hl str">&quot;agg[act]taaa|ttta[agt]cct&quot;</span><span class="hl sym">,</span>
+ <span class="hl str">&quot;aggg[acg]aaa|ttt[cgt]ccct&quot;</span><span class="hl sym">,</span>
+ <span class="hl str">&quot;agggt[cgt]aa|tt[acg]accct&quot;</span><span class="hl sym">,</span>
+ <span class="hl str">&quot;agggta[cgt]a|t[acg]taccct&quot;</span><span class="hl sym">,</span>
+ <span class="hl str">&quot;agggtaa[cgt]|[acg]ttaccct&quot;</span><span class="hl sym">,</span>
+<span class="hl sym">}</span>
+
+<span class="hl kwa">type</span> Subst <span class="hl kwa">struct</span> <span class="hl sym">{</span>
+ pat<span class="hl sym">,</span> repl string
+<span class="hl sym">}</span>
+
+<span class="hl kwa">var</span> substs <span class="hl sym">= []</span>Subst<span class="hl sym">{</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;B&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(c|g|t)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;D&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(a|g|t)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;H&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(a|c|t)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;K&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(g|t)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;M&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(a|c)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;N&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(a|c|g|t)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;R&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(a|g)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;S&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(c|g)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;V&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(a|c|g)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;W&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(a|t)&quot;</span><span class="hl sym">},</span>
+ Subst<span class="hl sym">{</span><span class="hl str">&quot;Y&quot;</span><span class="hl sym">,</span> <span class="hl str">&quot;(c|t)&quot;</span><span class="hl sym">},</span>
+<span class="hl sym">}</span>
+
+<span class="hl kwa">func</span> countMatches<span class="hl sym">(</span>pat string<span class="hl sym">,</span> bytes <span class="hl sym">[]</span>byte<span class="hl sym">)</span> int <span class="hl sym">{</span>
+ re <span class="hl sym">:=</span> regexp<span class="hl sym">.</span>MustCompile<span class="hl sym">(</span>pat<span class="hl sym">)</span>
+ n <span class="hl sym">:=</span> <span class="hl num">0</span>
+ <span class="hl kwa">for</span> <span class="hl sym">{</span>
+ e <span class="hl sym">:=</span> re<span class="hl sym">.</span>FindIndex<span class="hl sym">(</span>bytes<span class="hl sym">)</span>
+ <span class="hl kwa">if</span> e <span class="hl sym">==</span> nil <span class="hl sym">{</span>
+ <span class="hl kwa">break</span>
+ <span class="hl sym">}</span>
+ n<span class="hl sym">++</span>
+ bytes <span class="hl sym">=</span> bytes<span class="hl sym">[</span>e<span class="hl sym">[</span><span class="hl num">1</span><span class="hl sym">]:]</span>
+ <span class="hl sym">}</span>
+ <span class="hl kwa">return</span> n
+<span class="hl sym">}</span>
+
+<span class="hl kwa">func</span> main<span class="hl sym">() {</span>
+ runtime<span class="hl sym">.</span>GOMAXPROCS<span class="hl sym">(</span><span class="hl num">4</span><span class="hl sym">)</span>
+ bytes<span class="hl sym">,</span> err <span class="hl sym">:=</span> ioutil<span class="hl sym">.</span>ReadAll<span class="hl sym">(</span>os<span class="hl sym">.</span>Stdin<span class="hl sym">)</span>
+ <span class="hl kwa">if</span> err <span class="hl sym">!=</span> nil <span class="hl sym">{</span>
+ fmt<span class="hl sym">.</span>Fprintf<span class="hl sym">(</span>os<span class="hl sym">.</span>Stderr<span class="hl sym">,</span> <span class="hl str">&quot;can't read input: %s</span><span class="hl esc">\n</span><span class="hl str">&quot;</span><span class="hl sym">,</span> err<span class="hl sym">)</span>
+ os<span class="hl sym">.</span>Exit<span class="hl sym">(</span><span class="hl num">2</span><span class="hl sym">)</span>
+ <span class="hl sym">}</span>
+ ilen <span class="hl sym">:=</span> len<span class="hl sym">(</span>bytes<span class="hl sym">)</span>
+ <span class="hl slc">// Delete the comment lines and newlines</span>
+ bytes <span class="hl sym">=</span> regexp<span class="hl sym">.</span>MustCompile<span class="hl sym">(</span><span class="hl str">&quot;(&gt;[^</span><span class="hl esc">\n</span><span class="hl str">]+)?</span><span class="hl esc">\n</span><span class="hl str">&quot;</span><span class="hl sym">).</span>ReplaceAll<span class="hl sym">(</span>bytes<span class="hl sym">, []</span>byte<span class="hl sym">{})</span>
+ clen <span class="hl sym">:=</span> len<span class="hl sym">(</span>bytes<span class="hl sym">)</span>
+
+ mresults <span class="hl sym">:=</span> make<span class="hl sym">([]</span><span class="hl kwa">chan</span> int<span class="hl sym">,</span> len<span class="hl sym">(</span>variants<span class="hl sym">))</span>
+ <span class="hl kwa">for</span> i<span class="hl sym">,</span> s <span class="hl sym">:=</span> <span class="hl kwa">range</span> variants <span class="hl sym">{</span>
+ ch <span class="hl sym">:=</span> make<span class="hl sym">(</span><span class="hl kwa">chan</span> int<span class="hl sym">)</span>
+ mresults<span class="hl sym">[</span>i<span class="hl sym">] =</span> ch
+ <span class="hl kwa">go func</span><span class="hl sym">(</span>ss string<span class="hl sym">) {</span>
+ ch <span class="hl sym">&lt;-</span> countMatches<span class="hl sym">(</span>ss<span class="hl sym">,</span> bytes<span class="hl sym">)</span>
+ <span class="hl sym">}(</span>s<span class="hl sym">)</span>
+ <span class="hl sym">}</span>
+
+ lenresult <span class="hl sym">:=</span> make<span class="hl sym">(</span><span class="hl kwa">chan</span> int<span class="hl sym">)</span>
+ bb <span class="hl sym">:=</span> bytes
+ <span class="hl kwa">go func</span><span class="hl sym">() {</span>
+ <span class="hl kwa">for</span> _<span class="hl sym">,</span> sub <span class="hl sym">:=</span> <span class="hl kwa">range</span> substs <span class="hl sym">{</span>
+ bb <span class="hl sym">=</span> regexp<span class="hl sym">.</span>MustCompile<span class="hl sym">(</span>sub<span class="hl sym">.</span>pat<span class="hl sym">).</span>ReplaceAll<span class="hl sym">(</span>bb<span class="hl sym">, []</span>byte<span class="hl sym">(</span>sub<span class="hl sym">.</span>repl<span class="hl sym">))</span>
+ <span class="hl sym">}</span>
+ lenresult <span class="hl sym">&lt;-</span> len<span class="hl sym">(</span>bb<span class="hl sym">)</span>
+ <span class="hl sym">}()</span>
+
+ <span class="hl kwa">for</span> i<span class="hl sym">,</span> s <span class="hl sym">:=</span> <span class="hl kwa">range</span> variants <span class="hl sym">{</span>
+ fmt<span class="hl sym">.</span>Printf<span class="hl sym">(</span><span class="hl str">&quot;%s %d</span><span class="hl esc">\n</span><span class="hl str">&quot;</span><span class="hl sym">,</span> s<span class="hl sym">, &lt;-</span>mresults<span class="hl sym">[</span>i<span class="hl sym">])</span>
+ <span class="hl sym">}</span>
+ fmt<span class="hl sym">.</span>Printf<span class="hl sym">(</span><span class="hl str">&quot;</span><span class="hl esc">\n</span><span class="hl str">%d</span><span class="hl esc">\n</span><span class="hl str">%d</span><span class="hl esc">\n</span><span class="hl str">%d</span><span class="hl esc">\n</span><span class="hl str">&quot;</span><span class="hl sym">,</span> ilen<span class="hl sym">,</span> clen<span class="hl sym">, &lt;-</span>lenresult<span class="hl sym">)</span>
+<span class="hl sym">}</span>
View
25 website/websites/u64q/code/regexdna.6.go.log
@@ -0,0 +1,25 @@
+
+Sat, 16 Apr 2011 22:40:05 GMT
+
+MAKE:
+/usr/local/src/go/bin/6g -B -o regexdna.go-6.go.6 regexdna.go-6.go && \
+ /usr/local/src/go/bin/6l -o regexdna.go-6.go_run regexdna.go-6.go.6
+0.21s to complete and log all make actions
+
+COMMAND LINE:
+./regexdna.go-6.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
Please sign in to comment.
Something went wrong with that request. Please try again.