Created
July 28, 2019 01:15
-
-
Save danfarino/de0b1be94e5c544cca428bd0160c2cac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -Eeuo pipefail | |
cat > with.go <<EOF | |
package main | |
import ( | |
"fmt" | |
"strings" | |
) | |
func main() { | |
splits := strings.Split("a,b,c,d", ",") | |
n := len(splits) | |
for i := 1; i < n; i++ { | |
s := splits[i] | |
fmt.Printf("%s %d\n", s, n) | |
} | |
} | |
EOF | |
cat > without.go <<EOF | |
package main | |
import ( | |
"fmt" | |
"strings" | |
) | |
func main() { | |
splits := strings.Split("a,b,c,d", ",") | |
for i := 1; i < len(splits); i++ { | |
s := splits[i] | |
fmt.Printf("%s %d\n", s, len(splits)) | |
} | |
} | |
EOF | |
go build with.go | |
go build without.go | |
go tool objdump -S -s main.main with > with.asm | |
go tool objdump -S -s main.main without > without.asm | |
git --no-pager diff -w --ws-error-highlight=none --no-index with.asm without.asm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output on my machine: