Last active
February 28, 2019 19:01
-
-
Save dm03514/94e21863bc754ee89d670581efbe0650 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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