Benchmark script never completed on Docker (#211) (#428)

* Do not generate new fingerprint when connection fails

* Do not try to print latencies when all connections failed

* Update asgi_redis and channels versions in Dockerfile
This commit is contained in:
Paul 2016-11-05 15:16:27 +01:00 committed by Andrew Godwin
parent 1d93037bb7
commit 6c471ef915
3 changed files with 20 additions and 17 deletions

View File

@ -12,13 +12,13 @@ RUN apt-get update && \
# Install asgi_redis driver and most recent Daphne # Install asgi_redis driver and most recent Daphne
RUN pip install \ RUN pip install \
asgi_redis==0.8.3 \ asgi_redis==1.0.0 \
git+https://github.com/django/daphne.git@#egg=daphne git+https://github.com/django/daphne.git@#egg=daphne
# Clone Channels and install it # Clone Channels and install it
RUN git clone https://github.com/django/channels.git /srv/channels/ && \ RUN git clone https://github.com/django/channels.git /srv/channels/ && \
cd /srv/channels && \ cd /srv/channels && \
git reset --hard caa589ae708a1a66ba1bdcd24f5fd473040772bd && \ git reset --hard origin/master && \
python setup.py install python setup.py install
WORKDIR /srv/channels/testproject/ WORKDIR /srv/channels/testproject/

View File

@ -70,7 +70,6 @@ class MyClientProtocol(WebSocketClientProtocol):
"connect": True, "connect": True,
} }
else: else:
self.fingerprint = "".join(random.choice("abcdefghijklmnopqrstuvwxyz") for i in range(16))
stats[self.fingerprint] = { stats[self.fingerprint] = {
"sent": 0, "sent": 0,
"received": 0, "received": 0,
@ -168,22 +167,26 @@ class Benchmarker(object):
num_out_of_order += 1 num_out_of_order += 1
else: else:
num_good += 1 num_good += 1
# Some analysis on latencies
latency_mean = statistics.mean(latencies) if latencies:
latency_median = statistics.median(latencies) # Some analysis on latencies
latency_stdev = statistics.stdev(latencies) latency_mean = statistics.mean(latencies)
latency_95 = self.percentile(latencies, 0.95) latency_median = statistics.median(latencies)
latency_99 = self.percentile(latencies, 0.99) latency_stdev = statistics.stdev(latencies)
latency_95 = self.percentile(latencies, 0.95)
latency_99 = self.percentile(latencies, 0.99)
# Print results # Print results
print("-------") print("-------")
print("Sockets opened: %s" % len(stats)) print("Sockets opened: %s" % len(stats))
print("Latency stats: Mean %.3fs Median %.3fs Stdev %.3f 95%% %.3fs 95%% %.3fs" % ( if latencies:
latency_mean, print("Latency stats: Mean %.3fs Median %.3fs Stdev %.3f 95%% %.3fs 95%% %.3fs" % (
latency_median, latency_mean,
latency_stdev, latency_median,
latency_95, latency_stdev,
latency_99, latency_95,
)) latency_99,
))
print("Good sockets: %s (%.2f%%)" % (num_good, (float(num_good) / len(stats))*100)) print("Good sockets: %s (%.2f%%)" % (num_good, (float(num_good) / len(stats))*100))
print("Incomplete sockets: %s (%.2f%%)" % (num_incomplete, (float(num_incomplete) / len(stats))*100)) print("Incomplete sockets: %s (%.2f%%)" % (num_incomplete, (float(num_incomplete) / len(stats))*100))
print("Corrupt sockets: %s (%.2f%%)" % (num_corruption, (float(num_corruption) / len(stats))*100)) print("Corrupt sockets: %s (%.2f%%)" % (num_corruption, (float(num_corruption) / len(stats))*100))

View File

@ -13,6 +13,6 @@ services:
worker: worker:
image: channels-test image: channels-test
build: . build: .
command: python manage.py runworker command: python manage.py runworker --settings=testproject.settings.channels_redis
depends_on: depends_on:
- redis - redis