Example #1
0
File: vcache.go Project: taysom/va
// handler -
func handler(w http.ResponseWriter, r *http.Request) {
	tr := trace.Get(r.URL.Path[1:])
	dy := divup(trace.MaxBlock(tr), dx)
	m := Image{image.Rect(0, 0, dx, dy), make([][dx]bool, dy)}
	for _, t := range tr {
		for j := 0; j < int(t.Count); j++ {
			block := int(t.Block) + j
			y := block / dx
			x := block % dx
			m.Used[y][x] = true
		}
	}
	io.Copy(w, ShowImage(m))
}
Example #2
0
File: cache.go Project: taysom/va
func simulateCache(name string) {
	tr := trace.Get(name)
	noglass(tr)
	fmt.Println("size K #segs   MiB   secs    opt    avg    eff")
	for shift := uint(0); shift < MaxShift; shift++ {
		segment := make([]uint64, Segment(uint64(trace.MaxBlock(tr)), shift)+1)
		for _, t := range tr {
			for j := uint32(0); j < t.Count; j++ {
				segment[Segment(uint64(t.Block+j), shift)]++
			}
		}
		numsegs := nonzero(segment)
		avg := avgHits(segment)
		segsize := 1 << shift
		fmt.Printf(" %5d %5.3d %5.3d %6.2f %6.2f %6.2f %6.2f%%\n",
			4*segsize, numsegs, (numsegs<<shift)*PageSize/Meg,
			cost(shift, numsegs), ideal(shift, numsegs),
			avg, avg/float64(segsize)*100.)
	}
}