Index: third_party/grpc/tools/profiling/latency_profile/run_latency_profile.sh |
diff --git a/third_party/WebKit/LayoutTests/http/tests/websocket/workers/resources/echo_wsh.py b/third_party/grpc/tools/profiling/latency_profile/run_latency_profile.sh |
old mode 100644 |
new mode 100755 |
similarity index 51% |
copy from third_party/WebKit/LayoutTests/http/tests/websocket/workers/resources/echo_wsh.py |
copy to third_party/grpc/tools/profiling/latency_profile/run_latency_profile.sh |
index 429f58186e3fce43dc21e81e0f9d7e20c7e0bf70..54a25a9cb73ff23c34135c29298ab1fb7a77698d |
--- a/third_party/WebKit/LayoutTests/http/tests/websocket/workers/resources/echo_wsh.py |
+++ b/third_party/grpc/tools/profiling/latency_profile/run_latency_profile.sh |
@@ -1,4 +1,5 @@ |
-# Copyright 2010, Google Inc. |
+#!/bin/bash |
+# Copyright 2015, Google Inc. |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
@@ -27,20 +28,56 @@ |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+set -ex |
-from mod_pywebsocket import msgutil |
+cd $(dirname $0)/../../.. |
+BINS="sync_unary_ping_pong_test sync_streaming_ping_pong_test" |
+CPUS=`python -c 'import multiprocessing; print multiprocessing.cpu_count()'` |
-_GOODBYE_MESSAGE = 'Goodbye' |
+make CONFIG=basicprof -j$CPUS $BINS |
+mkdir -p reports |
-def web_socket_do_extra_handshake(request): |
- pass # Always accept. |
+# try to use pypy for generating reports |
+# each trace dumps 7-8gig of text to disk, and processing this into a report is |
+# heavyweight - so any speed boost is worthwhile |
+# TODO(ctiller): consider rewriting report generation in C++ for performance |
+if which pypy >/dev/null; then |
+ PYTHON=pypy |
+else |
+ PYTHON=python2.7 |
+fi |
+# start processes, interleaving report index generation |
+echo '<html><head></head><body>' > reports/index.html |
+for bin in $BINS |
+do |
+ bins/basicprof/$bin |
+ mv latency_trace.txt $bin.trace |
+ echo "<a href='$bin.txt'>$bin</a><br/>" >> reports/index.html |
+done |
+pids="" |
+# generate report pages... this will take some time |
+# run them in parallel: they take 1 cpu each |
+for bin in $BINS |
+do |
+ $PYTHON tools/profiling/latency_profile/profile_analyzer.py \ |
+ --source=$bin.trace --fmt=simple > reports/$bin.txt & |
+ pids+=" $!" |
+done |
+echo '</body></html>' >> reports/index.html |
-def web_socket_transfer_data(request): |
- while True: |
- line = msgutil.receive_message(request) |
- msgutil.send_message(request, line) |
- if line == _GOODBYE_MESSAGE: |
- return |
+# make sure we kill the report generation if something goes wrong |
+trap "kill $pids || true" 0 |
+ |
+# finally, wait for the background report generation to finish |
+for pid in $pids |
+do |
+ if wait $pid |
+ then |
+ echo "Finished $pid" |
+ else |
+ exit 1 |
+ fi |
+done |