]> Cypherpunks repositories - gostls13.git/commitdiff
change command-line argument to be
authorRoger Peppe <rogpeppe@gmail.com>
Mon, 30 Nov 2009 23:16:40 +0000 (15:16 -0800)
committerRuss Cox <rsc@golang.org>
Mon, 30 Nov 2009 23:16:40 +0000 (15:16 -0800)
unnamed, not require -n, in line with other
entries.

R=rsc
CC=r
https://golang.org/cl/162061

test/bench/chameneosredux.go
test/bench/timing.sh

index e957309f7ccfc6c70691a7d074adf3ff4b619798..6fa89e49cf6058afa4e63b689e2fefb6992685a8 100644 (file)
@@ -35,8 +35,11 @@ POSSIBILITY OF SUCH DAMAGE.
 
 package main
 
-import "fmt"
-import "flag"
+import (
+       "flag";
+       "fmt";
+       "strconv";
+)
 
 const (
        blue    = iota;
@@ -85,12 +88,13 @@ type result struct {
        same    int;
 }
 
-var np = flag.Int("n", 600, "count")
-var N int
+var n = 600
 
 func main() {
        flag.Parse();
-       N = *np;
+       if flag.NArg() > 0 {
+               n, _ = strconv.Atoi(flag.Arg(0))
+       }
 
        for c0 := 0; c0 < ncol; c0++ {
                for c1 := 0; c1 < ncol; c1++ {
@@ -137,8 +141,8 @@ func creature(info0 info, meetingplace chan rendez, ended chan result) {
                var othername int;
                // get access to rendez data and decide what to do.
                switch r := <-meetingplace; {
-               case r.n >= N:
-                       // if more than N meetings, then send our result data and exit.
+               case r.n >= n:
+                       // if no more meetings left, then send our result data and exit.
                        meetingplace <- rendez{n: r.n};
                        ended <- result{met, same};
                        return;
index 1bb14d3bad4bb956c836a0602618e554b05833f4..2227fbf0f9f577714bcfd63971913fe3835e93e6 100755 (executable)
@@ -176,8 +176,8 @@ threadring() {
 chameneos() {
        runonly echo 'chameneos 6000000'
        run 'gcc -O2 chameneosredux.c -lpthread' a.out 6000000
-#      run 'gccgo -O2 chameneosredux.go' a.out -n 6000000      # doesn't support the non-forward-decl variant
-       run 'gc chameneosredux' $O.out -n 6000000
+#      run 'gccgo -O2 chameneosredux.go' a.out 6000000 # doesn't support the non-forward-decl variant
+       run 'gc chameneosredux' $O.out 6000000
 }
 
 case $# in