Esempio n. 1
0
func _main(ts db.DB) {
	week := time.Hour * 24 * 7
	commits, err := ts.List(time.Now().Add(-week), time.Now())
	if err != nil {
		glog.Errorf("Failed to load commits: %s", err)
		return
	}
	if len(commits) > 50 {
		commits = commits[:50]
	}

	begin := time.Now()
	_, _, err = ts.TileFromCommits(commits)
	if err != nil {
		glog.Errorf("Failed to load Tile: %s", err)
		return
	}
	glog.Infof("Time to load tile: %v", time.Now().Sub(begin))
	// Now load a second time.
	begin = time.Now()
	_, _, err = ts.TileFromCommits(commits)
	if err != nil {
		glog.Errorf("Failed to load Tile: %s", err)
		return
	}
	glog.Infof("Time to load tile the second time: %v", time.Now().Sub(begin))
}
Esempio n. 2
0
func diff(tile *tiling.Tile, ts db.DB, isGold bool) error {
	commits := tile.Commits
	startTime := time.Unix(commits[0].CommitTime, 0)
	commitIDs, err := ts.List(startTime, time.Now())
	if err != nil {
		return err
	}

	glog.Infof("COMMIT ids:\n\n\n %s\n\n\n", spew.Sdump(commitIDs))
	glog.Infof("LOADING tile")

	traceDBTile, _, err := ts.TileFromCommits(commitIDs)
	if err != nil {
		return err
	}

	minLen := util.MinInt(len(commits), len(traceDBTile.Commits))
	tdbTraces := traceDBTile.Traces

	glog.Infof("Commits/traces in tilestore:  %d   -   %d", len(commits), len(tile.Traces))
	glog.Infof("Commits/traces in tracedb  :  %d   -   %d", len(traceDBTile.Commits), len(tdbTraces))

	count := 0
	matchingCount := 0
	for traceID, trace := range tile.Traces {
		_, ok := tdbTraces[traceID]
		if !ok {
			glog.Fatalf("Trace missing: %s", traceID)
		}

		v1 := trace.(*gtypes.GoldenTrace).Values[:minLen]
		v2 := tdbTraces[traceID].(*gtypes.GoldenTrace).Values[:minLen]
		identicalCount := 0
		indices := make([]int, 0, minLen)
		for idx, val := range v1 {
			if val == v2[idx] {
				identicalCount++
			} else {
				indices = append(indices, idx)
			}

		}
		if identicalCount != minLen {
			glog.Infof("Trace differs by %d / %d / %.2f,  %v", identicalCount, minLen, float64(identicalCount)/float64(minLen), indices)
		} else {
			matchingCount++
		}

		count++
	}
	glog.Infof("Compared %d traces. Matching: %d", count, matchingCount)

	return nil
}