-
-
Save stefantalpalaru/86751a89e06ca3d910ce 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
import golib | |
proc whisper(left, right: chan[int32]) {.goroutine.} = | |
left <- 1 + <-right | |
proc first_whisper(c: chan[int32]) {.goroutine.} = | |
c <- 1 | |
proc go_main() {.gomain.} = | |
## a slowdown in this scenario for gccgo-4.9.2 but not for go-1.4.2 | |
# runtime_gomaxprocsfunc(runtime_ncpu) | |
const n = 500000 | |
var | |
leftmost = make_chan(int32) | |
right = leftmost | |
left = leftmost | |
for i in 0..(n - 1): | |
right = make_chan(int32) | |
go whisper(left, right) | |
left = right | |
go first_whisper(right) | |
echo(<-leftmost) | |
golib_main() | |
# not reached |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment