This file contains 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
func BenchmarkFoo(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
// perform the operation we're analyzing | |
} | |
} |
This file contains 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
\documentclass[conference,10pt]{IEEEtran} | |
\usepackage[utf8]{inputenc} | |
\ifCLASSINFOpdf | |
\usepackage[pdftex]{graphicx} | |
\else | |
\usepackage[dvips]{graphicx} | |
\fi | |
\usepackage{algpseudocode} | |
\usepackage{amsmath} | |
\usepackage{color} |
This file contains 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
i, v, ok := reflect.Select(cases) | |
if !ok { | |
cases = append(cases[:i], cases[i+1:]...) | |
continue | |
} | |
out <- v.Interface().(int) |
This file contains 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
var cases []reflect.SelectCase | |
for _, c := range chans { | |
cases = append(cases, reflect.SelectCase{ | |
Dir: reflect.SelectRecv, | |
Chan: reflect.ValueOf(c), | |
}) | |
} |
This file contains 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
i, v, ok := reflect.Select(cases) | |
if !ok { | |
cases = append(cases[:i], cases[i+1:]...) | |
continue | |
} | |
out <- v.Interface().(int) |
This file contains 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
func merge(cs ...<-chan int) <-chan int { | |
out := make(chan int) | |
var wg sync.WaitGroup | |
wg.Add(len(cs)) | |
for _, c := range cs { | |
go func(c <-chan int) { | |
for v := range c { | |
out <- v | |
} | |
wg.Done() |
This file contains 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
func merge(cs ...<-chan int) <-chan int { | |
out := make(chan int) | |
for _, c := range cs { | |
go func(c <-chan int) { | |
for v := range c { | |
out <- v | |
} | |
}(c) | |
} |
This file contains 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
func main() { | |
a := asChan(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) | |
b := asChan(10, 11, 12, 13, 14, 15, 16, 17, 18, 19) | |
c := asChan(20, 21, 22, 23, 24, 25, 26, 27, 28, 29) | |
for v := range merge(a, b, c) { | |
fmt.Println(v) | |
} | |
} |
This file contains 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
func merge(cs ...<-chan int) <-chan int { | |
out := make(chan int) | |
for _, c := range cs { | |
go func() { | |
for v := range c { | |
out <- v | |
} | |
}() | |
} |
This file contains 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
FROM debian:jessie-backports | |
RUN apt-get update && apt-get install -y \ | |
asciidoc asciidoctor source-highlight graphviz \ | |
gcc libssl-dev uuid-dev libncurses-dev libcurl4-openssl-dev flex clang-3.5 bison \ | |
parallel | |
RUN apt-get install -y -t jessie-backports openjdk-8-jdk | |
# install golang | |
RUN apt-get install -y curl |