-
-
Save brendanashworth/4c669e16e387a02cf56dab218cf98914 to your computer and use it in GitHub Desktop.
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 ( | |
"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