Skip to content

Instantly share code, notes, and snippets.

@dm03514
Last active February 28, 2019 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dm03514/94e21863bc754ee89d670581efbe0650 to your computer and use it in GitHub Desktop.
Save dm03514/94e21863bc754ee89d670581efbe0650 to your computer and use it in GitHub Desktop.
package main
import (
"flag"
"fmt"
"time"
)
func main() {
interval := flag.Duration("interval-timeout", time.Second, "timeout to use")
flag.Parse()
fmt.Printf("hello, %s\n", interval)
start := time.Now()
ticker := time.NewTicker(*interval)
count := 0
for {
select {
case <-ticker.C:
count += 1
if count % 10 == 0 {
diff := time.Since(start)
fmt.Printf("%f ops/second\n", float64(count) / diff.Seconds())
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment