feat(#15): more benchmarks

master
Tomas Aparicio 11 years ago
parent 337252c2a0
commit 074a236dc3

@ -176,7 +176,7 @@ if err != nil {
options := bimg.Watermark{
Watermark{
Text: "Chuck Norris - Copyright (c) 2315",
Text: "Chuck Norris (c) 2315",
Opacity: 0.25,
Width: 200,
DPI: 100,

@ -75,7 +75,7 @@ func (i *Image) Thumbnail(pixels int) ([]byte, error) {
return i.Process(options)
}
// Insert an image to the existent one as watermark
// Add text as watermark on the given image
func (i *Image) Watermark(w Watermark) ([]byte, error) {
options := Options{Watermark: w}
return i.Process(options)

@ -209,7 +209,7 @@ func BenchmarkConvertToJpeg(b *testing.B) {
runBenchmarkResize("test.png", options, b)
}
func BenchmarkCrop(b *testing.B) {
func BenchmarkCropJpeg(b *testing.B) {
options := Options{
Width: 800,
Height: 600,
@ -217,6 +217,22 @@ func BenchmarkCrop(b *testing.B) {
runBenchmarkResize("test.jpg", options, b)
}
func BenchmarkCropPng(b *testing.B) {
options := Options{
Width: 800,
Height: 600,
}
runBenchmarkResize("test.png", options, b)
}
func BenchmarkCropWebP(b *testing.B) {
options := Options{
Width: 800,
Height: 600,
}
runBenchmarkResize("test.webp", options, b)
}
func BenchmarkExtractJpeg(b *testing.B) {
options := Options{
Top: 100,
@ -226,3 +242,83 @@ func BenchmarkExtractJpeg(b *testing.B) {
}
runBenchmarkResize("test.jpg", options, b)
}
func BenchmarkExtractPng(b *testing.B) {
options := Options{
Top: 100,
Left: 50,
AreaWidth: 600,
AreaHeight: 480,
}
runBenchmarkResize("test.png", options, b)
}
func BenchmarkExtractWebp(b *testing.B) {
options := Options{
Top: 100,
Left: 50,
AreaWidth: 600,
AreaHeight: 480,
}
runBenchmarkResize("test.webp", options, b)
}
func BenchmarkZoomJpeg(b *testing.B) {
options := Options{Zoom: 1}
runBenchmarkResize("test.jpg", options, b)
}
func BenchmarkZoomPng(b *testing.B) {
options := Options{Zoom: 1}
runBenchmarkResize("test.png", options, b)
}
func BenchmarkZoomWebp(b *testing.B) {
options := Options{Zoom: 1}
runBenchmarkResize("test.webp", options, b)
}
func BenchmarkWatermarkJpeg(b *testing.B) {
options := Options{
Watermark: Watermark{
Text: "Chuck Norris (c) 2315",
Opacity: 0.25,
Width: 200,
DPI: 100,
Margin: 150,
Font: "sans bold 12",
Background: Color{255, 255, 255},
},
}
runBenchmarkResize("test.webp", options, b)
}
func BenchmarkWatermarPng(b *testing.B) {
options := Options{
Watermark: Watermark{
Text: "Chuck Norris (c) 2315",
Opacity: 0.25,
Width: 200,
DPI: 100,
Margin: 150,
Font: "sans bold 12",
Background: Color{255, 255, 255},
},
}
runBenchmarkResize("test.png", options, b)
}
func BenchmarkWatermarWebp(b *testing.B) {
options := Options{
Watermark: Watermark{
Text: "Chuck Norris (c) 2315",
Opacity: 0.25,
Width: 200,
DPI: 100,
Margin: 150,
Font: "sans bold 12",
Background: Color{255, 255, 255},
},
}
runBenchmarkResize("test.webp", options, b)
}

@ -17,11 +17,11 @@ typedef struct {
} watermarkTextOptions;
typedef struct {
int Width;
int DPI;
int Margin;
int NoReplicate;
float Opacity;
int Width;
int DPI;
int Margin;
int NoReplicate;
float Opacity;
double Background[3];
} watermarkOptions;

Loading…
Cancel
Save