Пример #1
0
func BenchmarkGetParameters(b *testing.B) {
	group := "testdb"
	// generate the fingerprintsInMemory
	fingerprintsInMemory := make(map[string]Fingerprint)
	var fingerprintsOrdering []string
	db, err := bolt.Open(path.Join(RuntimeArgs.SourcePath, group+".db"), 0600, nil)
	if err != nil {
		log.Fatal(err)
	}
	db.View(func(tx *bolt.Tx) error {
		b := tx.Bucket([]byte("fingerprints"))
		c := b.Cursor()
		for k, v := c.First(); k != nil; k, v = c.Next() {
			fingerprintsInMemory[string(v)] = loadFingerprint(v)
			fingerprintsOrdering = append(fingerprintsOrdering, string(v))
		}
		return nil
	})
	db.Close()

	var ps = *NewFullParameters()
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		getParameters(group, &ps, fingerprintsInMemory, fingerprintsOrdering)
	}
}
Пример #2
0
func BenchmarkGetFingerprintInDatabase(b *testing.B) {
	for i := 0; i < b.N; i++ {
		group := "testdb"
		db, _ := bolt.Open(path.Join(RuntimeArgs.SourcePath, group+".db"), 0600, nil)
		db.View(func(tx *bolt.Tx) error {
			// Assume bucket exists and has keys
			b := tx.Bucket([]byte("fingerprints"))
			c := b.Cursor()
			for k, v := c.First(); k != nil; k, v = c.Next() {
				loadFingerprint(v)
				break
			}
			return nil
		})
		db.Close()
	}
}
Пример #3
0
func BenchmarkCrossValidation(b *testing.B) {
	group := "testdb"

	// generate the fingerprintsInMemory
	fingerprintsInMemory := make(map[string]Fingerprint)
	var fingerprintsOrdering []string
	db, err := bolt.Open(path.Join(RuntimeArgs.SourcePath, group+".db"), 0600, nil)
	if err != nil {
		log.Fatal(err)
	}
	db.View(func(tx *bolt.Tx) error {
		b := tx.Bucket([]byte("fingerprints"))
		c := b.Cursor()
		for k, v := c.First(); k != nil; k, v = c.Next() {
			fingerprintsInMemory[string(k)] = loadFingerprint(v)
			fingerprintsOrdering = append(fingerprintsOrdering, string(k))
		}
		return nil
	})
	db.Close()

	var ps = *NewFullParameters()
	getParameters(group, &ps, fingerprintsInMemory, fingerprintsOrdering)
	calculatePriors(group, &ps, fingerprintsInMemory, fingerprintsOrdering)
	var results = *NewResultsParameters()
	for n := range ps.Priors {
		ps.Results[n] = results
	}

	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		for n := range ps.Priors {
			ps.Priors[n].Special["MixIn"] = 0.5
			ps.Priors[n].Special["VarabilityCutoff"] = 0.005
			crossValidation(group, n, &ps, fingerprintsInMemory, fingerprintsOrdering)
			break
		}
	}
}