resources: Make the Exif benchmark filenames distinct

This commit is contained in:
Bjørn Erik Pedersen 2019-09-01 22:05:39 +02:00
parent 3becba7a98
commit 4f5011692a
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
2 changed files with 6 additions and 2 deletions

View file

@ -366,7 +366,7 @@ func BenchmarkImageExif(b *testing.B) {
spec := newTestResourceSpec(specDescriptor{fs: fs, c: c}) spec := newTestResourceSpec(specDescriptor{fs: fs, c: c})
images := make([]resource.Image, b.N) images := make([]resource.Image, b.N)
for i := 0; i < b.N; i++ { 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 return images
} }

View file

@ -154,10 +154,14 @@ func fetchImageForSpec(spec *Spec, c *qt.C, name string) resource.Image {
return img 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)) src, err := os.Open(filepath.FromSlash("testdata/" + name))
c.Assert(err, qt.IsNil) c.Assert(err, qt.IsNil)
workDir := spec.WorkingDir workDir := spec.WorkingDir
if len(targetPathAddends) > 0 {
addends := strings.Join(targetPathAddends, "_")
name = addends + "_" + name
}
targetFilename := filepath.Join(workDir, name) targetFilename := filepath.Join(workDir, name)
out, err := helpers.OpenFileForWriting(spec.Fs.Source, targetFilename) out, err := helpers.OpenFileForWriting(spec.Fs.Source, targetFilename)
c.Assert(err, qt.IsNil) c.Assert(err, qt.IsNil)