Only run benchmarks with -tags benchmark
Avoids creating temp database and stuff on a normal test run
This commit is contained in:
@@ -4,6 +4,8 @@
|
|||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
// You can obtain one at http://mozilla.org/MPL/2.0/.
|
// You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
// +build benchmark
|
||||||
|
|
||||||
package db_test
|
package db_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -42,19 +44,6 @@ func init() {
|
|||||||
fs.Replace(protocol.LocalDeviceID, firstHalf)
|
fs.Replace(protocol.LocalDeviceID, firstHalf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func genBlocks(n int) []protocol.BlockInfo {
|
|
||||||
b := make([]protocol.BlockInfo, n)
|
|
||||||
for i := range b {
|
|
||||||
h := make([]byte, 32)
|
|
||||||
for j := range h {
|
|
||||||
h[j] = byte(i + j)
|
|
||||||
}
|
|
||||||
b[i].Size = int32(i)
|
|
||||||
b[i].Hash = h
|
|
||||||
}
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
func tempDB() (*leveldb.DB, string) {
|
func tempDB() (*leveldb.DB, string) {
|
||||||
dir, err := ioutil.TempDir("", "syncthing")
|
dir, err := ioutil.TempDir("", "syncthing")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -28,6 +28,19 @@ func init() {
|
|||||||
|
|
||||||
const myID = 1
|
const myID = 1
|
||||||
|
|
||||||
|
func genBlocks(n int) []protocol.BlockInfo {
|
||||||
|
b := make([]protocol.BlockInfo, n)
|
||||||
|
for i := range b {
|
||||||
|
h := make([]byte, 32)
|
||||||
|
for j := range h {
|
||||||
|
h[j] = byte(i + j)
|
||||||
|
}
|
||||||
|
b[i].Size = int32(i)
|
||||||
|
b[i].Hash = h
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
func globalList(s *db.FileSet) []protocol.FileInfo {
|
func globalList(s *db.FileSet) []protocol.FileInfo {
|
||||||
var fs []protocol.FileInfo
|
var fs []protocol.FileInfo
|
||||||
s.WithGlobal(func(fi db.FileIntf) bool {
|
s.WithGlobal(func(fi db.FileIntf) bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user