Blame view

robot/unitTest/hero.lua 1.1 KB
4dc77717   zhouhaihai   压测
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
  local MsgPack = MsgPack
  local skynet = require "skynet"
  
  
  local TIME_WAIT = 10 
  
  local _M = class("hero", require("unitTest.unitTest"))
  
  function _M:start()
  	sendServer(actionCodes.Gm_clientRequest,  MsgPack.pack({cmd = "fb", pm1 = 10606}))
  	self:task()
  end
  
  
  local taskMap = {
  	drawHero = {100},
  	drawHero10 = {10},
  	createHeroRandom = {10000},
  }
  
  function _M:task()
  	local curTask = math.randWeight(taskMap, 1)
  	self[curTask](self)
  	skynet.timeout(TIME_WAIT * 100, handler(self, self.task))
  end
  
  function _M:drawHero()
  	sendServer(actionCodes.Gm_clientRequest,  MsgPack.pack({cmd = "get", pm1 = 3, pm2 = 400}))
7d31daa8   zhouhaihai   调整压测
29
  	requestServer(actionCodes.Hero_drawHeroRpc, MsgPack.pack({pool = 2, type = 1}))
4dc77717   zhouhaihai   压测
30
31
32
33
34
35
36
37
  end
  
  function _M:drawHero10()
  	sendServer(actionCodes.Gm_clientRequest,  MsgPack.pack({cmd = "get", pm1 = 3, pm2 = 4000}))
  	requestServer(actionCodes.Hero_drawHeroRpc, MsgPack.pack({pool = 2, type = 2}))
  end
  
  function _M:createHeroRandom()
a5fa0074   zhouhaihai   robot
38
39
  	sendServer(actionCodes.Gm_clientRequest,  MsgPack.pack({cmd = "get", pm1 = 722, pm2 = 40}))
  	requestServer(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack({itemId = 722}))
4dc77717   zhouhaihai   压测
40
41
42
43
  end
  
  
  return _M