| 
									
										
										
										
											2015-05-14 23:18:00 +02:00
										 |  |  | #!/usr/bin/env bash
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Convenience script to | 
					
						
							|  |  |  | # - For a given branch | 
					
						
							|  |  |  | # - Run  benchmark tests for a given package | 
					
						
							|  |  |  | # - Do the same for master | 
					
						
							|  |  |  | # - then compare the two runs with benchcmp | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-21 21:01:56 +02:00
										 |  |  | benchFilter=".*" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (( $# < 2 )); | 
					
						
							| 
									
										
										
										
											2015-05-14 23:18:00 +02:00
										 |  |  |   then | 
					
						
							| 
									
										
										
										
											2015-07-21 21:01:56 +02:00
										 |  |  |     echo "USAGE: ./bench.sh <git-branch> <package-to-bench> (and <benchmark filter> (regexp, optional))" | 
					
						
							| 
									
										
										
										
											2015-05-14 23:18:00 +02:00
										 |  |  |     exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-21 21:01:56 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | if [ $# -eq 3 ]; then | 
					
						
							|  |  |  |   benchFilter=$3 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-14 23:18:00 +02:00
										 |  |  | BRANCH=$1 | 
					
						
							|  |  |  | PACKAGE=$2 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | git checkout $BRANCH | 
					
						
							| 
									
										
										
										
											2015-07-21 21:01:56 +02:00
										 |  |  | go test -test.run=NONE -bench="$benchFilter" -test.benchmem=true ./$PACKAGE > /tmp/bench-$PACKAGE-$BRANCH.txt | 
					
						
							| 
									
										
										
										
											2015-05-14 23:18:00 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | git checkout master | 
					
						
							| 
									
										
										
										
											2015-07-21 21:01:56 +02:00
										 |  |  | go test -test.run=NONE -bench="$benchFilter" -test.benchmem=true ./$PACKAGE > /tmp/bench-$PACKAGE-master.txt | 
					
						
							| 
									
										
										
										
											2015-05-14 23:18:00 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | benchcmp /tmp/bench-$PACKAGE-master.txt /tmp/bench-$PACKAGE-$BRANCH.txt |