# -*- coding: utf-8 -*-#
# file: socketio
# Author: ShunZhe
# Date: 2021/6/26
import json
import logging
import re
import time
import gevent
import websocket
from locust import User
"""自定义websocket客户端"""
header = {
'Accept-Encoding': 'gzip, deflate, br',
'Connection': 'keep-alive',
'Content-Type': 'application/json;charset=UTF-8',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/87.0.4280.88 Safari/537.36 '
}
class SocketIO(object):
_locust_environment = None
start_time = 0
def __init__(self):
self.events = None
self.ws = None
def _require_failure(self, name, response_time, message, action, context, **kwargs):
"""统计失败请求数"""
self.events.request_failure.fire(
request_type="接收数据",
name=name,
response_time=response_time,
response_length=len(message),
exception=f'{
action} Content Error!',
context=context,
)
def _require_success(self, name, response_time, message, **kwargs):
"""统计成功请求数"""
se
Locust V1.5.3压测websocket接口
最新推荐文章于 2024-04-20 21:02:47 发布
本文介绍了如何利用Locust V1.5.3进行WebSocket接口的性能测试,通过webUI界面展示测试过程,并引用了locust-plugins插件作为参考。
摘要由CSDN通过智能技术生成