-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbench_test.go
50 lines (43 loc) · 1.14 KB
/
bench_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package state_test
import (
gc "launchpad.net/gocheck"
"github.com/juju/juju/state"
)
type BenchmarkSuite struct {
}
var _ = gc.Suite(&BenchmarkSuite{})
func (*BenchmarkSuite) BenchmarkAddUnit(c *gc.C) {
// TODO(rog) embed ConnSuite in BenchmarkSuite when
// gocheck calls appropriate fixture methods for benchmark
// functions.
var s ConnSuite
s.SetUpSuite(c)
defer s.TearDownSuite(c)
s.SetUpTest(c)
defer s.TearDownTest(c)
charm := s.AddTestingCharm(c, "wordpress")
svc := s.AddTestingService(c, "wordpress", charm)
c.ResetTimer()
for i := 0; i < c.N; i++ {
_, err := svc.AddUnit()
c.Assert(err, gc.IsNil)
}
}
func (*BenchmarkSuite) BenchmarkAddAndAssignUnit(c *gc.C) {
var s ConnSuite
s.SetUpSuite(c)
defer s.TearDownSuite(c)
s.SetUpTest(c)
defer s.TearDownTest(c)
charm := s.AddTestingCharm(c, "wordpress")
svc := s.AddTestingService(c, "wordpress", charm)
c.ResetTimer()
for i := 0; i < c.N; i++ {
unit, err := svc.AddUnit()
c.Assert(err, gc.IsNil)
err = s.State.AssignUnit(unit, state.AssignClean)
c.Assert(err, gc.IsNil)
}
}