From 20ccbc4c6814c86aecde3f1b43bdcc2981f0f50e Mon Sep 17 00:00:00 2001
From: Anmol Sethi <hi@nhooyr.io>
Date: Tue, 20 Aug 2019 22:49:56 -0400
Subject: [PATCH] Improve CONTRIBUTING.md

---
 .circleci/config.yml | 25 -------------------------
 ci/bench.sh          | 30 ------------------------------
 ci/run.sh            |  2 +-
 ci/test.sh           |  6 +++---
 docs/CONTRIBUTING.md | 26 +++++++++++++-------------
 websocket_test.go    |  2 +-
 6 files changed, 18 insertions(+), 73 deletions(-)
 delete mode 100755 ci/bench.sh

diff --git a/.circleci/config.yml b/.circleci/config.yml
index b4187ba..65b17aa 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -56,28 +56,6 @@ jobs:
       - store_test_results:
           path: ci/out
 
-  bench:
-    docker:
-      - image: nhooyr/websocket-ci
-    steps:
-      - checkout
-      - restore_cache:
-          keys:
-            - go-v3-{{ checksum "go.sum" }}
-            # Fallback to using the latest cache if no exact match is found.
-            - go-v3-
-      - run: ./ci/bench.sh
-      - store_artifacts:
-          path: ci/out
-          destination: out
-      - save_cache:
-          paths:
-            - /root/gopath
-            - /root/.cache/go-build
-          key: go-v3-{{ checksum "go.sum" }}
-      - store_test_results:
-          path: ci/out
-
 workflows:
   version: 2
   fmt:
@@ -89,6 +67,3 @@ workflows:
   test:
     jobs:
       - test
-  bench:
-    jobs:
-      - bench
diff --git a/ci/bench.sh b/ci/bench.sh
deleted file mode 100755
index fa11e32..0000000
--- a/ci/bench.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env bash
-
-set -euo pipefail
-cd "$(dirname "${0}")"
-cd "$(git rev-parse --show-toplevel)"
-
-mkdir -p ci/out/gobench
-benchArgs=(
-  "-vet=off"
-  "-run=^$"
-  "-bench=."
-  "-o=ci/out/websocket.test"
-  "-cpuprofile=ci/out/cpu.prof"
-  "-memprofile=ci/out/mem.prof"
-  "-blockprofile=ci/out/block.prof"
-  "-mutexprofile=ci/out/mutex.prof"
-  .
-)
-
-if [[ ${CI-} ]]; then
-  # https://circleci.com/docs/2.0/collect-test-data/
-  go test "${benchArgs[@]}" | tee /dev/stderr |
-    go run github.com/jstemmer/go-junit-report > ci/out/gobench/report.xml
-else
-  go test "${benchArgs[@]}"
-fi
-
-echo
-echo "Profiles are in ./ci/out/*.prof
-Keep in mind that every profiler Go provides is enabled so that may skew the benchmarks."
diff --git a/ci/run.sh b/ci/run.sh
index 56da2d9..904a759 100755
--- a/ci/run.sh
+++ b/ci/run.sh
@@ -8,4 +8,4 @@ cd "$(git rev-parse --show-toplevel)"
 
 ./ci/fmt.sh
 ./ci/lint.sh
-./ci/test.sh
+./ci/test.sh
\ No newline at end of file
diff --git a/ci/test.sh b/ci/test.sh
index 988add5..a746ab3 100755
--- a/ci/test.sh
+++ b/ci/test.sh
@@ -4,12 +4,12 @@ set -euo pipefail
 cd "$(dirname "${0}")"
 cd "$(git rev-parse --show-toplevel)"
 
-mkdir -p ci/out/gotest
-testFlags=(-race "-vet=off" "-coverprofile=ci/out/coverage.prof" "-coverpkg=./...")
+mkdir -p ci/out/websocket
+testFlags=(-race "-vet=off" "-bench=." "-coverprofile=ci/out/coverage.prof" "-coverpkg=./...")
 if [[ ${CI-} ]]; then
   # https://circleci.com/docs/2.0/collect-test-data/
   go test "${testFlags[@]}" -v ./... 2>&1 | tee /dev/stderr |
-    go run github.com/jstemmer/go-junit-report > ci/out/gotest/report.xml
+    go run github.com/jstemmer/go-junit-report > ci/out/websocket/testReport.xml
 else
   go test "${testFlags[@]}" ./...
 fi
diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md
index e5541ef..a183893 100644
--- a/docs/CONTRIBUTING.md
+++ b/docs/CONTRIBUTING.md
@@ -22,20 +22,20 @@ You can run tests normally with `go test`.
 You'll need the [Autobahn Test suite pip package](https://github.com/crossbario/autobahn-testsuite).
 In the future this dependency will be removed. See [#117](https://github.com/nhooyr/websocket/issues/117).
 
-On submission please check if CI has passed and if not, please correct your code such that it does.
-If necessary, you may run CI locally with the `ci/run.sh` script which will fmt, lint and test your code
-with coverage.
-You'll need [shellcheck](https://github.com/koalaman/shellcheck#installing), node and the
-Autobahn Test suite linked above.
+Please ensure CI passes for your changes. If necessary, you may run CI locally. The various steps are located
+in `ci/*.sh`.
 
-For coverage details locally, please see `ci/out/coverage.html` after running `ci/run.sh` or `ci/test.sh`.
-For remote coverage, you can use either [codecov](https://codecov.io/gh/nhooyr/websocket) or download the
-`coverage.html` artifact on the test step in CI.
+`ci/fmt.sh` requires node (specifically prettier).
+`ci/lint.sh` requires [shellcheck](https://github.com/koalaman/shellcheck#installing).
+`ci/test.sh` requires the [Autobahn Test suite pip package](https://github.com/crossbario/autobahn-testsuite).
+`ci/bench.sh` requires only Go.
+`ci/run.sh` runs everything in the above order and requires all of their dependencies.
 
-You can also run any of the CI steps individually. All of them are scripts in the `ci` directory.
+See [../ci/image/Dockerfile](../ci/image/Dockerfile) for the installation of the CI dependencies on ubuntu.
 
-See [../ci/image/Dockerfile](../ci/image/Dockerfile) for the
-installation of the CI dependencies on arch linux.
+For CI coverage, you can use either [codecov](https://codecov.io/gh/nhooyr/websocket) or click the
+`coverage.html` artifact on the test step in CI.
+For coverage details locally, please see `ci/out/coverage.html` after running `ci/run.sh` or `ci/test.sh`.
 
-You can benchmark the library with `./ci/benchmark.sh`. You only need Go to run that script.
-Benchmark profiles generated by that script are also available as artifacts on the bench step.
+Benchmark profiles generated by `bench.sh` are available as artifacts on the bench step so that they
+may be analyzed.
diff --git a/websocket_test.go b/websocket_test.go
index 2397709..cd6bdaf 100644
--- a/websocket_test.go
+++ b/websocket_test.go
@@ -1035,7 +1035,7 @@ func BenchmarkConn(b *testing.B) {
 	b.Run("echo", func(b *testing.B) {
 		for _, size := range sizes {
 			b.Run(strconv.Itoa(size), func(b *testing.B) {
-				benchConn(b, false, false, size)
+				benchConn(b, true, true, size)
 			})
 		}
 	})
-- 
GitLab