change image library and refactor thumbnails service

This commit is contained in:
David Christofas
2020-11-26 16:36:51 +01:00
parent c5a75291f9
commit c46a5598d4
18 changed files with 355 additions and 321 deletions
@@ -0,0 +1,47 @@
package thumbnail
import (
"image"
"os"
"path/filepath"
"testing"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/thumbnails/pkg/thumbnail/storage"
)
type NoOpManager struct {
storage.Storage
}
func (m NoOpManager) BuildKey(r storage.Request) string {
return ""
}
func (m NoOpManager) Set(username, key string, thumbnail []byte) error {
return nil
}
func BenchmarkGet(b *testing.B) {
sut := NewSimpleManager(
Resolutions{},
NoOpManager{},
log.NewLogger(),
)
res, _ := ParseResolution("32x32")
req := Request{
Resolution: res,
ETag: "1872ade88f3013edeb33decd74a4f947",
}
cwd, _ := os.Getwd()
p := filepath.Join(cwd, "../../testdata/oc.png")
f, _ := os.Open(p)
defer f.Close()
img, ext, _ := image.Decode(f)
req.Encoder = EncoderForType(ext)
for i := 0; i < b.N; i++ {
sut.Get(req, img)
}
}