Exemplo n.º 1
0
func (s *benchmarkSuite) BenchmarkManagedStorageCreate(c *gc.C) {
	db := s.Session.DB("a-database")
	txnRunner := jujuTxn.NewRunner(txn.NewRunner(db.C("txns")))
	rstore := storage.NewGridFS(db.Name, "prefix", s.Session)
	store := storage.NewManagedStorage(db, txnRunner, rstore)
	c.ResetTimer()
	const fileSize = 30 * 1024
	for i := 0; i < c.N; i++ {
		src := newDataSource(int64(i), fileSize)
		err := store.PutForEnvironment("env-uuid", fmt.Sprintf("file%d", i), src, fileSize)
		c.Assert(err, gc.IsNil)
	}
}
Exemplo n.º 2
0
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)
	}
}
Exemplo n.º 3
0
func (self *ProtobufClientSuite) BenchmarkSingle(c *gocheck.C) {
	var HEARTBEAT_TYPE = protocol.Request_HEARTBEAT
	prs := FakeHeartbeatServer()
	client := NewProtobufClient(prs.Listener.Addr().String(), time.Second)
	client.Connect()
	c.ResetTimer()
	for i := 0; i < c.N; i++ {
		responseChan := make(chan *protocol.Response, 1)
		heartbeatRequest := &protocol.Request{
			Type:     &HEARTBEAT_TYPE,
			Database: protocol.String(""),
		}
		rcw := cluster.NewResponseChannelWrapper(responseChan)
		client.MakeRequest(heartbeatRequest, rcw)
		<-responseChan
	}
}
Exemplo n.º 4
0
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)
	}
}
Exemplo n.º 5
0
func (s *benchmarkSuite) BenchmarkCreate(c *gc.C) {
	db := s.Session.DB("a-database")
	store := blobstore.New(db, "prefix")

	const fileSize = 30 * 1024
	hasher := sha256.New()
	c.ResetTimer()
	for i := 0; i < c.N; i++ {
		hasher.Reset()
		src := newDataSource(int64(i), fileSize)
		io.Copy(hasher, src)
		hash := hex(hasher.Sum(nil))
		exists, err := store.Create(hash, newDataSource(int64(i), fileSize))
		c.Assert(err, gc.IsNil)
		c.Assert(exists, gc.Equals, false)
	}
}