2016-05-13 06:50:33 +03:00
|
|
|
// Copyright 2015 The etcd Authors
|
2015-09-15 23:54:11 +03:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2016-04-25 22:32:58 +03:00
|
|
|
package mvcc
|
2015-09-09 19:49:28 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
2016-01-06 06:45:18 +03:00
|
|
|
|
2016-01-08 21:06:33 +03:00
|
|
|
"github.com/coreos/etcd/lease"
|
2016-04-25 22:32:58 +03:00
|
|
|
"github.com/coreos/etcd/mvcc/backend"
|
2015-09-09 19:49:28 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func BenchmarkKVWatcherMemoryUsage(b *testing.B) {
|
2016-01-06 06:45:18 +03:00
|
|
|
be, tmpPath := backend.NewDefaultTmpBackend()
|
2016-03-30 21:37:55 +03:00
|
|
|
watchable := newWatchableStore(be, &lease.FakeLessor{}, nil)
|
2016-01-06 06:45:18 +03:00
|
|
|
|
|
|
|
defer cleanup(watchable, be, tmpPath)
|
2015-11-03 04:43:41 +03:00
|
|
|
|
2016-01-03 02:59:32 +03:00
|
|
|
w := watchable.NewWatchStream()
|
2015-09-09 19:49:28 +03:00
|
|
|
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.StartTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
2016-02-26 19:55:28 +03:00
|
|
|
w.Watch([]byte(fmt.Sprint("foo", i)), nil, 0)
|
2015-09-09 19:49:28 +03:00
|
|
|
}
|
|
|
|
}
|