Knapsack problem/Bounded/Go test: Difference between revisions

m
fix typo
(Add Go test file and instructions)
 
m (fix typo)
 
(One intermediate revision by one other user not shown)
Line 38:
If you're unfamiliar with using benchmarks within go tests:
* Put the above into a <tt>*_test.go</tt> file in the same directory as the <tt>*.go</tt> file from [[Knapsack_problem/Bounded#Go]] (and with no other Go source files)
* Get and build [http://godoc.org/codegolang.google.comorg/px/go.tools/cmd/benchcmp benchcmp] if you don't already have it: "<code>go get -v codegolang.google.comorg/px/go.tools/cmd/benchcmp</code>"
* Run <code>go test -v -bench=. > bench.out.orig</code> (or <code>go test -bench=. | tee bench.out.orig</code> or some such)
* Make changes as desired
* Re-run the benchmark this time saving the output to a different file, e.g. <tt>bench.out</tt>
* Compare the results with "<code>benchcmp bench.out{.orig,}</code>" (or if you'reyour shell doesn't support "<code>{}</code>", with something like "<code>benchcmp bench.out.orig bench.out</code>")
For example, when I changed the code to use a <code>struct</code> as a map key instead of a string, the output was:
<pre>
Anonymous user