Commit 6b7e63bd authored by liyuanhong's avatar liyuanhong

优化了压力测试对内存的占用

parent 1ab9daaf
#coding: utf-8 #coding: utf-8
import json import json
import os
import re import re
import threading import threading
import time import time
...@@ -72,6 +73,7 @@ class FlvPressureTest(): ...@@ -72,6 +73,7 @@ class FlvPressureTest():
# 使用openvc去拉流 # 使用openvc去拉流
'''
def testServicePull(self, mobile,threadName): def testServicePull(self, mobile,threadName):
pullUrl = self.getPlayUrl(mobile,self.channel) pullUrl = self.getPlayUrl(mobile,self.channel)
# pullUrl = self.replaceHost(pullUrl, "video-test.vandyo.com:") # pullUrl = self.replaceHost(pullUrl, "video-test.vandyo.com:")
...@@ -93,21 +95,25 @@ class FlvPressureTest(): ...@@ -93,21 +95,25 @@ class FlvPressureTest():
self.threadInfoPull["threadObj"].pop(threadName) self.threadInfoPull["threadObj"].pop(threadName)
return return
self.threadInfoPull["threadObj"].pop(threadName) self.threadInfoPull["threadObj"].pop(threadName)
'''
'''
# 使用requests去拉流 # 使用requests去拉流
def testServicePull(self,mobile,threadName): def testServicePull(self,mobile,threadName):
pullUrl = self.getPlayUrl(mobile, self.channel) pullUrl = self.getPlayUrl(mobile, self.channel)
# pullUrl = self.replaceHost(pullUrl, "video-test.vandyo.com:") # pullUrl = self.replaceHost(pullUrl, "video-test.vandyo.com:")
try: try:
requests.get(pullUrl) r = requests.get(pullUrl,stream=True)
with open(os.devnull, 'w') as f:
for chunk in r.iter_content(chunk_size=512):
if chunk:
f.write(str(chunk))
except: except:
traceback.print_exc() traceback.print_exc()
self.threadInfoPull["threadObj"].pop(threadName) self.threadInfoPull["threadObj"].pop(threadName)
return return
self.threadInfoPull["threadObj"].pop(threadName) self.threadInfoPull["threadObj"].pop(threadName)
'''
################################################ ################################################
# 启动推流线程 # 启动推流线程
......
...@@ -34,13 +34,13 @@ def getPressTestObj(): ...@@ -34,13 +34,13 @@ def getPressTestObj():
test = FlvPressureTest() test = FlvPressureTest()
test.setHost("10.100.11.125") test.setHost("10.100.11.125")
test.setPort(1078) test.setPort(1078)
test.setMobileStart(50000000000) # 开始的设备号 (累加) test.setMobileStart(90000000000) # 开始的设备号 (累加)
test.setChannel(1) # 设置频道号 test.setChannel(1) # 设置频道号
test.setTerNum(30) # 要启动的推拉流线程 test.setTerNum(1) # 要启动的推拉流线程
test.setIsOpenPullStream(1) # 设置是否开启拉流 test.setIsOpenPullStream(1) # 设置是否开启拉流
test.setIsShowFrame(0) # 拉流是否显示预览画面 (压力测试都应该填:0) test.setIsShowFrame(0) # 拉流是否显示预览画面 (压力测试都应该填:0)
test.setSendDur(0.007) # 设置socket 发送数据间隔 test.setSendDur(0.007) # 设置socket 发送数据间隔
test.setFlvPath("flv/aaa3.flv") # 设置视频路劲 test.setFlvPath("flv/yyy.flv") # 设置视频路劲
test.start() test.start()
return test return test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment