本文整理汇总了Golang中gopkg/in/check/v1.C.ResetTimer方法的典型用法代码示例。如果您正苦于以下问题:Golang C.ResetTimer方法的具体用法?Golang C.ResetTimer怎么用?Golang C.ResetTimer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gopkg/in/check/v1.C
的用法示例。
在下文中一共展示了C.ResetTimer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: BenchmarkCleanupMetrics
// BenchmarkCleanupMetrics needs to add metrics each time over the cycle.
// Because of this the benchmark includes addmetric time
func (*BenchmarkSuite) BenchmarkCleanupMetrics(c *gc.C) {
numberOfMetrics := 50
var s ConnSuite
s.SetUpSuite(c)
defer s.TearDownSuite(c)
s.SetUpTest(c)
defer s.TearDownTest(c)
oldTime := time.Now().Add(-(state.CleanupAge))
charm := s.AddTestingCharm(c, "wordpress")
svc := s.AddTestingService(c, "wordpress", charm)
unit, err := svc.AddUnit()
c.Assert(err, jc.ErrorIsNil)
serviceCharmURL, _ := svc.CharmURL()
err = unit.SetCharmURL(serviceCharmURL)
c.Assert(err, jc.ErrorIsNil)
c.ResetTimer()
for i := 0; i < c.N; i++ {
for i := 0; i < numberOfMetrics; i++ {
m, err := unit.AddMetrics(utils.MustNewUUID().String(), oldTime, "", []state.Metric{{}})
c.Assert(err, jc.ErrorIsNil)
err = m.SetSent()
c.Assert(err, jc.ErrorIsNil)
}
err := s.State.CleanupOldMetrics()
c.Assert(err, jc.ErrorIsNil)
}
}
示例2: benchmarkAddMetrics
func benchmarkAddMetrics(metricsPerBatch, batches int, c *gc.C) {
var s ConnSuite
s.SetUpSuite(c)
defer s.TearDownSuite(c)
s.SetUpTest(c)
defer s.TearDownTest(c)
now := time.Now()
metrics := make([]state.Metric, metricsPerBatch)
for i := range metrics {
metrics[i] = state.Metric{
Key: "metricKey",
Value: "keyValue",
Time: now,
}
}
charm := s.AddTestingCharm(c, "wordpress")
svc := s.AddTestingService(c, "wordpress", charm)
unit, err := svc.AddUnit()
c.Assert(err, jc.ErrorIsNil)
serviceCharmURL, _ := svc.CharmURL()
err = unit.SetCharmURL(serviceCharmURL)
c.Assert(err, jc.ErrorIsNil)
c.ResetTimer()
for i := 0; i < c.N; i++ {
for n := 0; n < batches; n++ {
_, err := unit.AddMetrics(utils.MustNewUUID().String(), now, "", metrics)
c.Assert(err, jc.ErrorIsNil)
}
}
}
示例3: BenchmarkExample
func (s *exampleSuite) BenchmarkExample(c *gc.C) {
serverEndpoint, err := serve(func(endpoint string) (http.Handler, error) {
return targetService(endpoint, s.authEndpoint, s.authPublicKey)
})
c.Assert(err, gc.IsNil)
c.ResetTimer()
for i := 0; i < c.N; i++ {
resp, err := clientRequest(serverEndpoint)
c.Assert(err, gc.IsNil)
c.Assert(resp, gc.Equals, "hello, world\n")
}
}
示例4: BenchmarkAddAndAssignUnit
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, jc.ErrorIsNil)
err = s.State.AssignUnit(unit, state.AssignClean)
c.Assert(err, jc.ErrorIsNil)
}
}
示例5: BenchmarkAddUnit
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, jc.ErrorIsNil)
}
}