本文整理汇总了Golang中testing.B.Cursor方法的典型用法代码示例。如果您正苦于以下问题:Golang B.Cursor方法的具体用法?Golang B.Cursor怎么用?Golang B.Cursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testing.B
的用法示例。
在下文中一共展示了B.Cursor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: BenchmarkGetParameters
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: BenchmarkGetFingerprintInDatabase
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: BenchmarkCrossValidation
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
}
}
}