mirror of
https://github.com/django/daphne.git
synced 2025-07-13 09:22:17 +03:00
Installable benchmark package. (#501)
* Make benchmark installable module. * Use passed url in the Benchmarker constructor. * Correct percentile output. * Import reactor globally. Since it used in the benchmarker.
This commit is contained in:
parent
1542343392
commit
5c74ee587e
|
@ -3,9 +3,11 @@ from __future__ import unicode_literals
|
||||||
import time
|
import time
|
||||||
import random
|
import random
|
||||||
import statistics
|
import statistics
|
||||||
from autobahn.twisted.websocket import WebSocketClientProtocol, \
|
from autobahn.twisted.websocket import (
|
||||||
WebSocketClientFactory
|
WebSocketClientProtocol,
|
||||||
|
WebSocketClientFactory,
|
||||||
|
)
|
||||||
|
from twisted.internet import reactor
|
||||||
|
|
||||||
stats = {}
|
stats = {}
|
||||||
|
|
||||||
|
@ -92,9 +94,7 @@ class Benchmarker(object):
|
||||||
self.rate = rate
|
self.rate = rate
|
||||||
self.spawn = spawn
|
self.spawn = spawn
|
||||||
self.messages = messages
|
self.messages = messages
|
||||||
self.factory = WebSocketClientFactory(
|
self.factory = WebSocketClientFactory(self.url)
|
||||||
args.url,
|
|
||||||
)
|
|
||||||
self.factory.protocol = MyClientProtocol
|
self.factory.protocol = MyClientProtocol
|
||||||
self.factory.num_messages = self.messages
|
self.factory.num_messages = self.messages
|
||||||
self.factory.message_rate = self.rate
|
self.factory.message_rate = self.rate
|
||||||
|
@ -180,7 +180,7 @@ class Benchmarker(object):
|
||||||
print("-------")
|
print("-------")
|
||||||
print("Sockets opened: %s" % len(stats))
|
print("Sockets opened: %s" % len(stats))
|
||||||
if latencies:
|
if latencies:
|
||||||
print("Latency stats: Mean %.3fs Median %.3fs Stdev %.3f 95%% %.3fs 95%% %.3fs" % (
|
print("Latency stats: Mean %.3fs Median %.3fs Stdev %.3f 95%% %.3fs 99%% %.3fs" % (
|
||||||
latency_mean,
|
latency_mean,
|
||||||
latency_median,
|
latency_median,
|
||||||
latency_stdev,
|
latency_stdev,
|
||||||
|
@ -200,7 +200,6 @@ if __name__ == '__main__':
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from twisted.python import log
|
from twisted.python import log
|
||||||
from twisted.internet import reactor
|
|
||||||
|
|
||||||
# log.startLogging(sys.stdout)
|
# log.startLogging(sys.stdout)
|
||||||
|
|
||||||
|
|
7
testproject/setup.py
Normal file
7
testproject/setup.py
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='channels-benchmark',
|
||||||
|
py_modules=['benchmark'],
|
||||||
|
install_requires=['autobahn', 'Twisted'],
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user