resources: Make the Exif benchmark filenames distinct
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 1 Sep 2019 20:05:39 +0000 (22:05 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 1 Sep 2019 20:05:39 +0000 (22:05 +0200)
resources/image_test.go
resources/testhelpers_test.go

index dc5e0a2172cbee23da026795af5ea3cd2e24ef9f..6d879d2717a18deae997c5b78f984c8cd4fa457a 100644 (file)
@@ -366,7 +366,7 @@ func BenchmarkImageExif(b *testing.B) {
                spec := newTestResourceSpec(specDescriptor{fs: fs, c: c})
                images := make([]resource.Image, b.N)
                for i := 0; i < b.N; i++ {
-                       images[i] = fetchImageForSpec(spec, c, "sunset.jpg")
+                       images[i] = fetchResourceForSpec(spec, c, "sunset.jpg", strconv.Itoa(i)).(resource.Image)
                }
                return images
        }
index bc24fb8f24d687354f28a8464f503a4a7a193326..3e072545227f661176d7f79cc84df05c69756f50 100644 (file)
@@ -154,10 +154,14 @@ func fetchImageForSpec(spec *Spec, c *qt.C, name string) resource.Image {
        return img
 }
 
-func fetchResourceForSpec(spec *Spec, c *qt.C, name string) resource.ContentResource {
+func fetchResourceForSpec(spec *Spec, c *qt.C, name string, targetPathAddends ...string) resource.ContentResource {
        src, err := os.Open(filepath.FromSlash("testdata/" + name))
        c.Assert(err, qt.IsNil)
        workDir := spec.WorkingDir
+       if len(targetPathAddends) > 0 {
+               addends := strings.Join(targetPathAddends, "_")
+               name = addends + "_" + name
+       }
        targetFilename := filepath.Join(workDir, name)
        out, err := helpers.OpenFileForWriting(spec.Fs.Source, targetFilename)
        c.Assert(err, qt.IsNil)