Beispiel #1
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
}
Beispiel #2
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))
}
Beispiel #3
0
func _main(tile *tiling.Tile, ts db.DB) {
	commits := []*db.CommitID{}
	for i, commit := range tile.Commits {
		cid := &db.CommitID{
			Timestamp: time.Unix(commit.CommitTime, 0),
			ID:        commit.Hash,
			Source:    "master",
		}
		commits = append(commits, cid)
		values := map[string]*db.Entry{}
		if !*skip {
			for traceid, tr := range tile.Traces {
				if !tr.IsMissing(i) {
					values[traceid] = &db.Entry{
						Params: tr.Params(),
					}
					if *gold {
						values[traceid].Value = []byte(tr.(*types.GoldenTrace).Values[i])
					} else {
						values[traceid].Value = ptypes.BytesFromFloat64(tr.(*ptypes.PerfTrace).Values[i])
					}
				}
			}
			glog.Infof("Adding: %d", i)
			if err := ts.Add(cid, values); err != nil {
				glog.Errorf("Failed to add data: %s", err)
			}
		}
	}
	begin := time.Now()
	if len(commits) > 50 {
		commits = commits[:50]
	}
	_, err := ts.TileFromCommits(commits)
	if err != nil {
		glog.Fatalf("Failed to scan Tile: %s", err)
	}
	glog.Infof("Time to load tile: %v", time.Now().Sub(begin))
}