本文整理汇总了Golang中flag.Int函数的典型用法代码示例。如果您正苦于以下问题:Golang Int函数的具体用法?Golang Int怎么用?Golang Int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Int函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
// Parse input flags
var socket *string = flag.String("socket", "", "Unix domain socket to connect to")
var num_clients *int = flag.Int("num_clients", 100, "Number of clients to launch")
var concurrency *int = flag.Int("concurrency", 10, "Number of clients running concurrently")
var num_cpu *int = flag.Int("cpu_use", 2, "Number of CPUs to use")
flag.Parse()
// Set thew number of CPUs to use
runtime.GOMAXPROCS(*num_cpu)
// Create a chan to comunicate with the processes
// This channel will imitate a semaphore
p := 0
sem := make(chan bool, *concurrency)
// Place the initial values in the semaphore
for i := 0; i < *concurrency; i++ {
sem <- true
}
// Run the test clients
for <-sem; p < *num_clients; _, p = <-sem, p+1 {
go createTestClient(*socket, "unix", sem)
}
// Wait for the remaining processes to finish
for j := 0; j < *concurrency-1; _, j = <-sem, j+1 {
}
fmt.Println(p, "processes finished")
}
开发者ID:royger,项目名称:DAD,代码行数:26,代码来源:test_server.go
示例2: main
func main() {
var statsdHost = flag.String("statsd_host", "127.0.0.1", "Statsd host")
var statsdPort = flag.Int("statsd_port", 8125, "Statsd host")
var nodename = flag.String("nodename", "riak", "Riak node name")
var riakHost = flag.String("riak_host", "127.0.0.1", "Riak host")
var riakHttpPort = flag.Int("riak_http_port", 8098, "Riak HTTP port")
flag.Parse()
// First ping to node to make sure it works
err := pingRiak(*riakHost, *riakHttpPort)
if err != nil {
log.Fatalf("Error: %v", err)
os.Exit(1)
}
statsd := fmt.Sprintf("%s:%d", *statsdHost, *statsdPort)
addr, err := net.ResolveUDPAddr("udp", statsd)
if err != nil {
log.Fatalf("Couldn't resolve UDP addr: %v", err)
os.Exit(1)
}
conn, err := net.DialUDP("udp", nil, addr)
if err != nil {
log.Fatalf("Couldn't connect to statsd at %s", statsd)
os.Exit(1)
}
// every 60s run hit the stats endpoint and then send to statsd
interval := time.NewTicker(time.Second * 60)
for _ = range interval.C {
go getAndSendRiakMetrics(conn, *nodename, *riakHost, *riakHttpPort)
}
}
开发者ID:jjmalina,项目名称:riak-statsd,代码行数:32,代码来源:main.go
示例3: main
func main() {
endpoint := flag.String("endpoint", "http://127.0.0.1:4001", "etcd HTTP endpoint")
rWrites := flag.Int("write-requests", 50000, "number of writes")
cWrites := flag.Int("concurrent-writes", 500, "number of concurrent writes")
watches := flag.Int("watches", 500, "number of writes")
flag.Parse()
for i := 0; i < *watches; i++ {
key := strconv.Itoa(i)
go watch(*endpoint, key)
}
wChan := make(chan int, *cWrites)
for i := 0; i < *cWrites; i++ {
go write(*endpoint, (*rWrites / *cWrites), wChan)
}
for i := 0; i < *cWrites; i++ {
<-wChan
log.Printf("Completed %d writes", (*rWrites / *cWrites))
}
}
开发者ID:lichia,项目名称:hydra,代码行数:25,代码来源:bench.go
示例4: main
func main() {
numCPU := runtime.NumCPU()
runtime.GOMAXPROCS(numCPU)
obliteration := flag.Int("concurrency", 10, "threads and connections to use for load generation")
host := flag.String("zk", "master.mesos:2181", "host:port for zk")
size := flag.Int("size", 1024, "bytes per key written")
ratio := flag.Float64("ratio", 0.2, "0 to 1 ratio of reads to writes. 0 is all writes, 1 is all reads.")
flag.Parse()
value := gen(*size)
conns := []*zk.Conn{}
for i := 0; i < *obliteration; i++ {
cli, _, err := zk.Connect([]string{*host}, 5*time.Second)
if err != nil {
fmt.Printf("error connecting to zk: %v\n", err)
os.Exit(1)
}
conns = append(conns, cli)
}
doRpc := func() {
cli := conns[rand.Intn(len(conns))]
bench(cli, value, *ratio)
}
loghisto.PrintBenchmark("benchmark1234", uint(*obliteration), doRpc)
}
开发者ID:spacejam,项目名称:zk-obliterator,代码行数:29,代码来源:zk-obliterator.go
示例5: main
func main() {
uuid := flag.String("uuid", "1BEAC099-BEAC-BEAC-BEAC-BEAC09BEAC09", "iBeacon UUID")
major := flag.Int("major", 0, "iBeacon major value (uint16)")
minor := flag.Int("minor", 0, "iBeacon minor value (uint16)")
power := flag.Int("power", -57, "iBeacon measured power (int8)")
d := flag.Duration("duration", 1*time.Minute, "advertising duration")
verbose := flag.Bool("verbose", false, "dump all events")
flag.Parse()
ble := goble.New()
ble.SetVerbose(*verbose)
ble.Init()
var utsname xpc.Utsname
xpc.Uname(&utsname)
log.Println(utsname.Release)
time.Sleep(1 * time.Second)
log.Println("Start Advertising", *uuid, *major, *minor, *power)
ble.StartAdvertisingIBeacon(xpc.MustUUID(*uuid), uint16(*major), uint16(*minor), int8(*power))
time.Sleep(*d)
log.Println("Stop Advertising")
ble.StopAdvertising()
}
开发者ID:raff,项目名称:goble,代码行数:27,代码来源:beacon.go
最后编辑: kuteng 文档更新时间: 2021-08-23 19:14 作者:kuteng