当前位置: 首页>>代码示例>>Golang>>正文


Golang C.ResetTimer方法代码示例

本文整理汇总了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)
	}
}
开发者ID:Pankov404,项目名称:juju,代码行数:29,代码来源:bench_test.go

示例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)
		}
	}
}
开发者ID:Pankov404,项目名称:juju,代码行数:30,代码来源:bench_test.go

示例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")
	}
}
开发者ID:jrwren,项目名称:macaroon-bakery,代码行数:12,代码来源:example_test.go

示例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)
	}
}
开发者ID:Pankov404,项目名称:juju,代码行数:16,代码来源:bench_test.go

示例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)
	}
}
开发者ID:Pankov404,项目名称:juju,代码行数:17,代码来源:bench_test.go


注:本文中的gopkg/in/check/v1.C.ResetTimer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。