syafdia / go-exercise Goto Github PK
View Code? Open in Web Editor NEWExercise for learning Go programming language
Exercise for learning Go programming language
Hello , when I comment out the code that counts goroutines I get deadlock, and with it the program doesn't stop (I'm using single file version)
https://play.golang.org/p/4p5hNa7pQc0
goos: darwin
goarch: amd64
pkg: github.com/syafdia/go-exercise/src/concurrency/pipeline
cpu: Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
BenchmarkWithPipelineModule-8 3 338075456 ns/op 1128 B/op 16 allocs/op
BenchmarkWithoutPipelineModule-8 2 608577913 ns/op 820 B/op 7 allocs/op
BenchmarkWithPipelineStd-8 157275 7123 ns/op 333 B/op 6 allocs/op
PASS
coverage: 89.5% of statements
ok github.com/syafdia/go-exercise/src/concurrency/pipeline 18.334s
func BenchmarkWithPipelineStd(b *testing.B) {
outC := make(chan interface{}, b.N)
var wg sync.WaitGroup
wg.Add(b.N)
for i := 0; i < b.N; i++ {
go func(i int) {
defer wg.Done()
outC <- addFoo(addQuoute(square(multiplyTwo(i))))
}(i)
}
wg.Wait()
close(outC)
for range outC {
// Do nothing, just for drain out channel
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.