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
<!doctype html> | |
<html class="no-js" lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>d3 webGL force graph with PIXI.js</title> | |
<meta name="description" content=""> | |
<meta name="theme-color" content="#000000"> | |
</head> | |
<body> | |
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=default"></script> |
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
func benchmarkRegularStableKeys(b *testing.B, workerCount int) { | |
runtime.GOMAXPROCS(workerCount) | |
rm := NewRegularIntMap() | |
populateMap(b.N, rm) | |
var wg sync.WaitGroup | |
wg.Add(workerCount) | |
// Holds our final results, to prevent compiler optimizations. |
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
func BenchmarkLoadRegularFound(b *testing.B) { | |
nums := nrand(b.N) | |
rm := NewRegularIntMap() | |
for _, v := range nums { | |
rm.Store(v, v) | |
} | |
currentResult := 0 | |
b.ResetTimer() |
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
func BenchmarkDeleteRegular(b *testing.B) { | |
nums := nrand(b.N) | |
rm := NewRegularIntMap() | |
for _, v := range nums { | |
rm.Store(v, v) | |
} | |
b.ResetTimer() | |
for _, v := range nums { | |
rm.Delete(v) |
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
func nrand(n int) []int { | |
i := make([]int, n) | |
for ind := range i { | |
i[ind] = rand.Int() | |
} | |
return i | |
} | |
func BenchmarkStoreRegular(b *testing.B) { | |
nums := nrand(b.N) |
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
func syncMapUsage() { | |
fmt.Println("sync.Map test (Go 1.9+ only)") | |
fmt.Println("----------------------------") | |
// Create the threadsafe map. | |
var sm sync.Map | |
// Fetch an item that doesn't exist yet. | |
result, ok := sm.Load("hello") | |
if ok { |
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 RegularIntMap | |
type RegularIntMap struct { | |
sync.RWMutex | |
internal map[int]int | |
} | |
func NewRegularIntMap() *RegularIntMap { | |
return &RegularIntMap{ | |
internal: make(map[int]int), |
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 ( | |
"fmt" | |
"math/rand" | |
"os" | |
"os/signal" | |
"sync/atomic" | |
"time" | |
) |
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 ( | |
"fmt" | |
"math/rand" | |
"time" | |
) | |
const totalEnemies = 1 |
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 ( | |
"fmt" | |
"math/rand" | |
"sync" | |
"time" | |
) | |
const totalEnemies = 2 |