You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Explicit Race Condition Test - Counting to 10000 - 200 concurrent requesters
$ go test -run TestExplicitRace ./races/ -v -total-requests=10000 -concurrent-requests=200
=== RUN TestExplicitRace
Num Requests TO Make: 10000
Final Count: 9884
TestExplicitRace: explicit_test.go:69: expected 10000 requests: received 9884
--- FAIL: TestExplicitRace (1.35s)
FAIL
FAIL github.com/dm03514/grokking-go/candidates-and-contexts/races 1.475s
FAIL
Explicit Race - Race Detector
$ go test -run TestExplicitRace ./races/ -v -total-requests=10000 -concurrent-requests=200 -race
=== RUN TestExplicitRace
==================
WARNING: DATA RACE
Read at 0x00c000128350 by goroutine 550:
github.com/dm03514/grokking-go/candidates-and-contexts/races.TestExplicitRace.func1.1()
/Users/danielmican/go/src/github.com/dm03514/grokking-go/candidates-and-contexts/races/explicit_test.go:28 +0x4a
net/http.HandlerFunc.ServeHTTP()
/usr/local/Cellar/go/1.14.4/libexec/src/net/http/server.go:2012 +0x51
net/http.(*ServeMux).ServeHTTP()
/usr/local/Cellar/go/1.14.4/libexec/src/net/http/server.go:2387 +0x288
net/http.serverHandler.ServeHTTP()
/usr/local/Cellar/go/1.14.4/libexec/src/net/http/server.go:2807 +0xce
net/http.(*conn).serve()
/usr/local/Cellar/go/1.14.4/libexec/src/net/http/server.go:1895 +0x837
Previous write at 0x00c000128350 by goroutine 491:
github.com/dm03514/grokking-go/candidates-and-contexts/races.TestExplicitRace.func1.1()
/Users/danielmican/go/src/github.com/dm03514/grokking-go/candidates-and-contexts/races/explicit_test.go:28 +0x60
net/http.HandlerFunc.ServeHTTP()
/usr/local/Cellar/go/1.14.4/libexec/src/net/http/server.go:2012 +0x51
net/http.(*ServeMux).ServeHTTP()
/usr/local/Cellar/go/1.14.4/libexec/src/net/http/server.go:2387 +0x288
net/http.serverHandler.ServeHTTP()
/usr/local/Cellar/go/1.14.4/libexec/src/net/http/server.go:2807 +0xce
net/http.(*conn).serve()
/usr/local/Cellar/go/1.14.4/libexec/src/net/http/server.go:1895 +0x837
HTTP Handler - Synchronized Counter - SUCCESS
var mu = new(sync.Mutex)
counter := 0
go func() {
http.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
mu.Lock()
defer mu.Unlock()
counter = counter + 1
fmt.Fprintln(w, "Hello, client")
}))
log.Fatal(http.ListenAndServe(":8080", nil))
}()
$ gotest-runTestSynchronizedMutexNoRace ./races/-v-total-requests=10000-concurrent-requests=200===RUNTestSynchronizedMutexNoRaceNumRequests TO Make: 10000
Final Count: 10000---PASS: TestSynchronizedMutexNoRace (0.86s)
PASSokgithub.com/dm03514/grokking-go/candidates-and-contexts/races0.986s
Race Detector
$ go test -run TestSynchronizedMutexNoRace ./races/ -v -total-requests=10000 -concurrent-requests=200 -race
=== RUN TestSynchronizedMutexNoRace
Num Requests TO Make: 10000
Final Count: 10000
--- PASS: TestSynchronizedMutexNoRace (4.27s)
PASS
ok github.com/dm03514/grokking-go/candidates-and-contexts/races 4.476s
Monitor Test - SUCCESS! - Multiple Concurrent Producers - Single Consumer
$ go test -run TestMonitorNoRace ./races/ -v -total-requests=10000 -concurrent-requests=200
=== RUN TestMonitorNoRace
Num Requests TO Make: 10000
Final Count: 10000
--- PASS: TestMonitorNoRace (0.68s)
PASS
ok github.com/dm03514/grokking-go/candidates-and-contexts/races 0.804s
The text was updated successfully, but these errors were encountered:
HTTP Handler - Non-Synchronized Counter
Explicit Race Condition Test - Counting to 10000 - 200 concurrent requesters
$ go test -run TestExplicitRace ./races/ -v -total-requests=10000 -concurrent-requests=200 === RUN TestExplicitRace Num Requests TO Make: 10000 Final Count: 9884 TestExplicitRace: explicit_test.go:69: expected 10000 requests: received 9884 --- FAIL: TestExplicitRace (1.35s) FAIL FAIL github.com/dm03514/grokking-go/candidates-and-contexts/races 1.475s FAIL
Explicit Race - Race Detector
HTTP Handler - Synchronized Counter - SUCCESS
Race Detector
HTTP Handler - Monitor Pattern - SUCCESS
Monitor Test - SUCCESS! - Multiple Concurrent Producers - Single Consumer
The text was updated successfully, but these errors were encountered: