예제 #1
0
파일: node_test.go 프로젝트: dilgerma/scope
func child(t *testing.T, r render.Renderer, id string) detailed.NodeSummary {
	s, ok := detailed.MakeNodeSummary(fixture.Report, r.Render(fixture.Report, render.FilterNoop)[id])
	if !ok {
		t.Fatalf("Expected node %s to be summarizable, but wasn't", id)
	}
	return s.SummarizeMetrics()
}
예제 #2
0
// Individual nodes.
func handleNode(ctx context.Context, renderer render.Renderer, _ render.Decorator, report report.Report, w http.ResponseWriter, r *http.Request) {
	var (
		vars       = mux.Vars(r)
		topologyID = vars["topology"]
		nodeID     = vars["id"]
		rendered   = renderer.Render(report, nil)
		node, ok   = rendered[nodeID]
	)
	if !ok {
		http.NotFound(w, r)
		return
	}
	respondWith(w, http.StatusOK, APINode{Node: detailed.MakeNode(topologyID, report, rendered, node)})
}
예제 #3
0
func benchmarkStats(b *testing.B, r render.Renderer) {
	report, err := loadReport()
	if err != nil {
		b.Fatal(err)
	}
	b.ReportAllocs()
	b.ResetTimer()

	for i := 0; i < b.N; i++ {
		// No way to tell if this was successful :(
		b.StopTimer()
		render.ResetCache()
		b.StartTimer()
		benchmarkStatsResult = r.Stats(report, render.FilterNoop)
	}
}
예제 #4
0
func benchmarkRender(b *testing.B, r render.Renderer) {

	report, err := loadReport()
	if err != nil {
		b.Fatal(err)
	}
	b.ReportAllocs()
	b.ResetTimer()

	for i := 0; i < b.N; i++ {
		b.StopTimer()
		render.ResetCache()
		b.StartTimer()
		benchmarkRenderResult = r.Render(report, render.FilterNoop)
		if len(benchmarkRenderResult) == 0 {
			b.Errorf("Rendered topology contained no nodes")
		}
	}
}
예제 #5
0
func decorateWithStats(rpt report.Report, renderer render.Renderer, decorator render.Decorator) topologyStats {
	var (
		nodes     int
		realNodes int
		edges     int
	)
	for _, n := range renderer.Render(rpt, decorator) {
		nodes++
		if n.Topology != render.Pseudo {
			realNodes++
		}
		edges += len(n.Adjacency)
	}
	renderStats := renderer.Stats(rpt, decorator)
	return topologyStats{
		NodeCount:          nodes,
		NonpseudoNodeCount: realNodes,
		EdgeCount:          edges,
		FilteredNodes:      renderStats.FilteredNodes,
	}
}
예제 #6
0
// Full topology.
func handleTopology(ctx context.Context, renderer render.Renderer, decorator render.Decorator, report report.Report, w http.ResponseWriter, r *http.Request) {
	respondWith(w, http.StatusOK, APITopology{
		Nodes: detailed.Summaries(report, renderer.Render(report, decorator)),
	})
}