]> Cypherpunks repositories - gostls13.git/commitdiff
test/bench: use range in reverse-complement
authorRuss Cox <rsc@golang.org>
Sat, 5 Dec 2009 05:44:29 +0000 (21:44 -0800)
committerRuss Cox <rsc@golang.org>
Sat, 5 Dec 2009 05:44:29 +0000 (21:44 -0800)
1.9s gcc reverse-complement.c

reverse-complement.go
4.5s / 3.5s original, with/without bounds checks
3.5s / 3.3s bounds check reduction
3.3s / 2.8s smarter garbage collector
2.6s / 2.3s assembler bytes.IndexByte
2.5s / 2.1s even smarter garbage collector
2.3s / 2.1s fix optimizer unnecessary spill bug
2.0s / 1.9s change loop to range (this CL)

R=r
https://golang.org/cl/166072

test/bench/reverse-complement.go

index 60e14dba8c140b19208fb0eb2acd0c47d705e5c6..a685e43b5b072c9330bdc68c4e50c7345f23eedf 100644 (file)
@@ -86,9 +86,9 @@ func main() {
                        }
 
                        // This loop is the bottleneck.
-                       for r := 0; r < len(line); r++ {
+                       for _, c := range line {
                                w--;
-                               buf[w] = complement[line[r]];
+                               buf[w] = complement[c];
                        }
                }