func main() { flag.Parse() if *cpuprofile != "" { f, _ := os.Create(*cpuprofile) pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() } start := time.Now() for i := 0; i < iterations; i++ { tree := quadtree.NewQuadTree(0, treeSize, 0, treeSize, elemCount/6) for i := 0; i < elemCount; i++ { x := rand.Float64() * treeSize y := rand.Float64() * treeSize tree.Insert(x, y, i) } vs := []*quadtree.View{tree.View()} col := make([]interface{}, 0, elemCount) fun := func(x, y float64, e interface{}) { col = append(col, e) } tree.Survey(vs, fun) tree.Del(tree.View(), quadtree.SimpleDelete()) println(col) } total := time.Now().Sub(start) println(fstrconv.ItoaComma(elemCount)) println(total.String()) secs := total.Nanoseconds() / (1000 * 1000 * 1000) if secs == 0 { return } println(secs) perSec := elemCount / secs println(fstrconv.ItoaComma(perSec), "elements per second") }
func printSummary(msgs, nanos, failedWrites, failedReads int64, name string) { sMsgs := fstrconv.ItoaComma(msgs) sNanos := fstrconv.ItoaComma(nanos) sFailedWrites := fstrconv.ItoaComma(failedWrites) sFailedReads := fstrconv.ItoaComma(failedReads) print(fmt.Sprintf("\n%s\nMsgs %s\nNanos %s\nfailedWrites %s\nfailedReads %s\n", name, sMsgs, sNanos, sFailedWrites, sFailedReads)) }
func TestMin(t *testing.T) { rand.Seed(1) for i := 0; i < 1000*1000; i++ { a := rand.Int63n(1000 * 1000 * 1000) b := rand.Int63n(1000 * 1000 * 1000) m := Min(a, b) om := simpleMin(a, b) if m != om { as := fstrconv.ItoaComma(a) bs := fstrconv.ItoaComma(b) ms := fstrconv.ItoaComma(m) t.Errorf("Problem with min of %s, %s - min returned %s", as, bs, ms) } } }
func doPerf(log bool) { flag.Parse() data := getData() if log { orderCount := fstrconv.ItoaComma(int64(len(data))) println(orderCount, "OrderNodes Built") } start := time.Now() defer func() { if log { println("Running Time: ", time.Now().Sub(start).String()) } }() startProfile() defer endProfile() singleThreaded(log, data) }