def testSingleBatch(self): mc = MemcacheConnection((MEMCACHE_IP, 11211)) #batch = mc.batch() #batch.set('bset_1', 10) #batch.set('bset_2', 20) #batch.get('bset_1') #batch.get('bset_2') #result = batch.execute() #print result.receive() #print result.receive() #print result.receive() #print result.receive() N = 400 B = 400 with unittest.timer() as tmr: for i in range(N): batch = mc.batch() for j in range(B): batch.set('test2', 'hello world!') for _ in batch.execute( ): #TODO why do we need to read out results? pass print 'single server batch set keys/sec', tmr.sec(B * N)
def testExtraSingle(self): """test stuff that only makes sense on a single server connection""" mc = MemcacheConnection((MEMCACHE_IP, 11212)) res1, v1 = mc.version() res2, v2 = mc.version() self.assertEquals(MemcacheResult.OK, res1) self.assertEquals(MemcacheResult.OK, res2) self.assertEquals(str, type(v1)) self.assertEquals(str, type(v2)) self.assertTrue(len(v1) > 1) self.assertEquals(v1, v2)
def testExtraSingle(self): """test stuff that only makes sense on a single server connection""" mc = MemcacheConnection((MEMCACHE_IP, 11211)) res1, v1 = mc.version() res2, v2 = mc.version() self.assertEquals(MemcacheResult.OK, res1) self.assertEquals(MemcacheResult.OK, res2) self.assertEquals(str, type(v1)) self.assertEquals(str, type(v2)) self.assertTrue(len(v1) > 1) self.assertEquals(v1, v2)
def testSingleBatch(self): mc = MemcacheConnection((MEMCACHE_IP, 11212)) #batch = mc.batch() #batch.set('bset_1', 10) #batch.set('bset_2', 20) #batch.get('bset_1') #batch.get('bset_2') #result = batch.execute() #print result.receive() #print result.receive() #print result.receive() #print result.receive() N = 400 B = 400 with unittest.timer() as tmr: for i in range(N): batch = mc.batch() for j in range(B): batch.set('test2', 'hello world!') for _ in batch.execute(): #TODO why do we need to read out results? pass print 'single server batch set keys/sec', tmr.sec(B * N)
def testBasicSingle(self): mc = MemcacheConnection((MEMCACHE_IP, 11211)) self.sharedTestBasic(mc)