Skip to content

Instantly share code, notes, and snippets.

@brendanashworth
Created July 25, 2017 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brendanashworth/4c669e16e387a02cf56dab218cf98914 to your computer and use it in GitHub Desktop.
Save brendanashworth/4c669e16e387a02cf56dab218cf98914 to your computer and use it in GitHub Desktop.
package main
import (
"io"
"io/ioutil"
"testing"
"github.com/minio/minio-go"
)
func createClient() (*minio.Client, error) {
endpoint := "localhost:9000"
accessKeyID := "..."
secretAccessKey := "..."
useSSL := false
return minio.New(endpoint, accessKeyID, secretAccessKey, useSSL)
}
// Fails when run with long test duration (~10 seconds).
func BenchmarkMinioGetObject(b *testing.B) {
client, err := createClient()
if err != nil {
b.Fatal(err)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
obj, err := client.GetObject("bigobject", "largeobject")
if err != nil {
b.Fatal(err)
}
// Copy first two bytes to /dev/null then repeat.
_, err = io.CopyN(ioutil.Discard, obj, 2)
if err != nil {
b.Fatal(err)
}
obj.Close()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment