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
package gobench | |
func GoMapAdd() { | |
m := map[int]int{0: 0, 1: 1} | |
_ = m[0] + m[1] | |
} | |
func GoStructAdd() { | |
m := struct{ a, b int }{0, 1} | |
_ = m.a + m.b |
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
package gobench | |
import ( | |
"testing" | |
) | |
func BenchmarkGoMapAdd(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
GoMapAdd() |
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
package bench2 | |
import ( | |
"encoding/json" | |
) | |
func MarshalMap() { | |
m := map[int]int{0: 0, 1: 1} | |
json.Marshal(m) | |
} |
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
package bench2 | |
import ( | |
"testing" | |
) | |
func BenchmarkMarshalMap(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
MarshalMap() |
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
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
//"net/http" | |
//"time" | |
) | |
// NewWorker creates, and returns a new Worker object. Its only argument |
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 scipy.io.wavfile import read #import wav audio related functions | |
import matplotlib.pyplot as plt #for plotting | |
fs , x = read('/home/karthic/Downloads/kalimba.wav') #x is an array of integers containing all the samples of the wav file | |
print "sample rate = " ,fs #sample rate of the wav file | |
print "Total samples in the wav audio: ",x.size #total number of samples in the wav audio | |
print "Length of wav file in seconds: ",x.size/float(fs) | |
#number of samples / sampling rate gives the length of the wav file in seconds | |
plt.plot(x) #plot the wav sampling |
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
package main | |
import ( | |
"github.com/Shopify/sarama" | |
"crypto/tls" | |
"crypto/x509" | |
"encoding/json" | |
"flag" | |
"fmt" |
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
// Package redirect is middleware for redirecting certain requests | |
// to other locations. | |
package redirect | |
import ( | |
"fmt" | |
"html" | |
"net/http" | |
"github.com/mholt/caddy/middleware" |
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
package main | |
import "fmt" | |
func main() { | |
fmt.Println(Fib(3)) | |
} | |
//Fib inefficent version | |
func Fib(n int) 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
package main | |
import ( | |
"testing" | |
) | |
func BenchmarkFibV1(b *testing.B) { | |
// run the Fib function b.N times | |
for n := 0; n < b.N; n++ { | |
Fib(10) |
OlderNewer