Skip to content

Commit

Permalink
Merge pull request #16 from hageldave/devel2.0
Browse files Browse the repository at this point in the history
merge devel2.0 to master for fourier artifact to be deployed
  • Loading branch information
hageldave authored Sep 26, 2018
2 parents c1ecbec + ad8fb21 commit 9ef45f4
Show file tree
Hide file tree
Showing 19 changed files with 2,499 additions and 414 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ jdk:

before_script:
- "export DISPLAY=:99.0"
- "export _JAVA_OPTIONS=\"-Xms2g -Xmx2g -verbose:gc\""
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start (x virtual frame buffer for gui testing)

script: mvn -X -pl :imagingkit-core clean test
script: mvn -P travis -X clean test jacoco:report

env:
global:
- secure: "fy+WvtV6xOwvHjIt+qINm3Idqg8ItyHa5hIzkB6e7Dv9xOrtSLTiHO+lkyiKIZ/RePuJibd1G+iy+Kn3nF5G0FDcndEmG2xCeSxM69ijOGd463Zi2Ys9+rpqXGwtgUt7Nin/Rw3UAa52Tx7jii4YVF6WuSjDdwAovKT5U+cmBfgGxfTSaZVlbE1he2zh/WJ2lk3UfsUhQY0H+lSGOembIYOG+WiE7OpouczAIwn8mk9DzK/u3Y3IK/FsFuC0mQfuE6sz96JNMaU7HrpGwKDZr3AstZstV2BHgjV7R8nLO8WXr5zASu3YTdTu52moX2xe1rMJL+oVN4Hn0tNDJR41gKP2G5x/eRFLX57LHl/QaXubopjU7RJFT4ZvFjd4G0EqybB6TtKQW4gL+1dn4dhKmayLGC+tEHBJ6u9yPPJefAYJdEm0scetNmhk+YV+uJuOqaZArBf3rgikdhHUPgSNeq9LxVgq4em58Jb9PVQLyuuIxmnfFmYp44eX8u0sWxgEvoGwTgpshMwSMnTQLaI2IUZX/zrbUIWe+eiY1Fq6zbqHaX4mkigu3vIWaLZfx26e2lsHbJgGe5+aalafXPSuHcInxu54KQY7KD6/34Z31oum2ho+039OpaK7UVI1tOWrqK8xB/MhGthEFaPs5aCOcxWgflqvsT7HR8fB1xaD7Gk="

after_success:
- mvn -P travis -pl :imagingkit-core -DrepoToken=$COVERALLSTOKEN clean test jacoco:report coveralls:report
- mvn -P coveralls -DrepoToken=$COVERALLSTOKEN coveralls:report -e -X
- bash <(curl -s https://codecov.io/bash)
22 changes: 22 additions & 0 deletions ImagingKit_Core/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2017 David Hägele

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

19 changes: 13 additions & 6 deletions ImagingKit_Core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<version>0.8.0</version>
<executions>
<execution>
<id>prepare-agent</id>
Expand All @@ -144,14 +144,21 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.1.0</version>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>coveralls</id>
<build>
<plugins>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.1.0</version>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<scm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ private static void hsv2rgb_continuous(PixelBase px)
default: px.setRGB_fromDouble_preserveAlpha(v,t,p);break;
}
}

private static void rgb2ycbcr_continuous(PixelBase px)
{
double r = px.r_asDouble(), g = px.g_asDouble(), b = px.b_asDouble();
Expand Down
196 changes: 101 additions & 95 deletions ImagingKit_Core/src/test/java/hageldave/imagingkit/core/Performance.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package hageldave.imagingkit.core;

import java.util.Arrays;
import java.util.Random;
import java.util.function.Consumer;

Expand All @@ -8,9 +9,8 @@ public class Performance {
public static void main(String[] args) {

long time;
long[] times = new long[7];
String[] methods = new String[times.length];
int numLoops = 15;
int[][] problemsizes = new int[][]{{128,128},{1280,720},{1920,1080},{5568,3712}};
int numLoops = 8;

int contrastLuminance = 128;
double contrastLum = contrastLuminance/255.0;
Expand All @@ -28,113 +28,119 @@ public static void main(String[] args) {
px.setRGB_fromDouble_preserveAlpha(r, g, b);
};

Img img = new Img(6000, 4000);
{ // init img;
Random rand = new Random();
for(int i = 0; i < img.getData().length; i++){
img.getData()[i] = Pixel.argb(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255), rand.nextInt(255));
}
}
Img imgBackup = img.copy();

img.setSpliteratorMinimumSplitSize(Math.max(img.numValues()/512, 1024));
System.out.println("spliterator min size :" + img.getSpliteratorMinimumSplitSize());

for(int i = 0; i < numLoops; i++){

methods[0] = "serial for";
System.out.println(methods[0]);
time = System.currentTimeMillis();
{
for(int k = 0; k < img.numValues(); k++){
int color = img.getData()[k];
double r = Pixel.r_normalized(color);
double g = Pixel.g_normalized(color);
double b = Pixel.b_normalized(color);
double luminance = r*0.2126 + g*0.7152 + b*0.0722;
double lumDif = luminance-contrastLum;
r += lumDif*contrastIntensity;
g += lumDif*contrastIntensity;
b += lumDif*contrastIntensity;
img.getData()[k] = Pixel.argb_fromNormalized(Pixel.a_normalized(color), r, g, b);
for(int[] probsize:problemsizes){

long[] times = new long[7];
String[] methods = new String[times.length];

Img img = new Img(probsize[0],probsize[1]);
{ // init img;
Random rand = new Random();
for(int i = 0; i < img.getData().length; i++){
img.getData()[i] = Pixel.argb(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255), rand.nextInt(255));
}
}
times[0] += System.currentTimeMillis()-time;
imgBackup.copyArea(0, 0, img.getWidth(), img.getHeight(), img, 0, 0);
Img imgBackup = img.copy();

img.setSpliteratorMinimumSplitSize(Math.max(img.numValues()/512, 1024));
System.out.println("spliterator min size :" + img.getSpliteratorMinimumSplitSize());

for(int i = 0; i < numLoops; i++){

methods[0] = "serial for";
// System.out.println(methods[0]);
time = System.currentTimeMillis();
{
for(int k = 0; k < img.numValues(); k++){
int color = img.getData()[k];
double r = Pixel.r_normalized(color);
double g = Pixel.g_normalized(color);
double b = Pixel.b_normalized(color);
double luminance = r*0.2126 + g*0.7152 + b*0.0722;
double lumDif = luminance-contrastLum;
r += lumDif*contrastIntensity;
g += lumDif*contrastIntensity;
b += lumDif*contrastIntensity;
img.getData()[k] = Pixel.argb_fromNormalized(Pixel.a_normalized(color), r, g, b);
}
}
times[0] += System.currentTimeMillis()-time;
imgBackup.copyArea(0, 0, img.getWidth(), img.getHeight(), img, 0, 0);


methods[1] = "serial forEach";
System.out.println(methods[1]);
time = System.currentTimeMillis();
{
img.forEach(action);
}
times[1] += System.currentTimeMillis()-time;
imgBackup.copyArea(0, 0, img.getWidth(), img.getHeight(), img, 0, 0);
methods[1] = "serial forEach";
// System.out.println(methods[1]);
time = System.currentTimeMillis();
{
img.forEach(action);
}
times[1] += System.currentTimeMillis()-time;
imgBackup.copyArea(0, 0, img.getWidth(), img.getHeight(), img, 0, 0);


methods[2] = "serial forEach default";
System.out.println(methods[2]);
time = System.currentTimeMillis();
{
img.forEach_defaultimpl(action);
}
times[2] += System.currentTimeMillis()-time;
imgBackup.copyArea(0, 0, img.getWidth(), img.getHeight(), img, 0, 0);
methods[2] = "serial forEach default";
// System.out.println(methods[2]);
time = System.currentTimeMillis();
{
img.forEach_defaultimpl(action);
}
times[2] += System.currentTimeMillis()-time;
imgBackup.copyArea(0, 0, img.getWidth(), img.getHeight(), img, 0, 0);


methods[3] = "serial Stream";
System.out.println(methods[3]);
time = System.currentTimeMillis();
{
img.stream().forEach(action);
}
times[3] += System.currentTimeMillis()-time;
imgBackup.copyArea(0, 0, img.getWidth(), img.getHeight(), img, 0, 0);
methods[3] = "serial Stream";
// System.out.println(methods[3]);
time = System.currentTimeMillis();
{
img.stream().forEach(action);
}
times[3] += System.currentTimeMillis()-time;
imgBackup.copyArea(0, 0, img.getWidth(), img.getHeight(), img, 0, 0);


methods[4] = "parallel forEach";
System.out.println(methods[4]);
time = System.currentTimeMillis();
{
img.forEach(true,action);
}
times[4] += System.currentTimeMillis()-time;
imgBackup.copyArea(0, 0, img.getWidth(), img.getHeight(), img, 0, 0);
methods[4] = "parallel forEach";
// System.out.println(methods[4]);
time = System.currentTimeMillis();
{
img.forEach(true,action);
}
times[4] += System.currentTimeMillis()-time;
imgBackup.copyArea(0, 0, img.getWidth(), img.getHeight(), img, 0, 0);


methods[5] = "parallel Stream";
System.out.println(methods[5]);
time = System.currentTimeMillis();
{
img.stream(true).forEach(action);
}
times[5] += System.currentTimeMillis()-time;
imgBackup.copyArea(0, 0, img.getWidth(), img.getHeight(), img, 0, 0);


methods[6] = "parallel converted";
System.out.println(methods[6]);
time = System.currentTimeMillis();
{
img.forEach(PixelConvertingSpliterator.getDoubleArrayConverter(), true, arr-> {
double luminance = arr[0]*0.2126 + arr[1]*0.7152 + arr[2]*0.0722;
double lumDif = luminance-contrastLum;
arr[0] += lumDif*contrastIntensity;
arr[1] += lumDif*contrastIntensity;
arr[2] += lumDif*contrastIntensity;
});
}
times[6] += System.currentTimeMillis()-time;
imgBackup.copyArea(0, 0, img.getWidth(), img.getHeight(), img, 0, 0);
methods[5] = "parallel Stream";
// System.out.println(methods[5]);
time = System.currentTimeMillis();
{
img.stream(true).forEach(action);
}
times[5] += System.currentTimeMillis()-time;
imgBackup.copyArea(0, 0, img.getWidth(), img.getHeight(), img, 0, 0);


methods[6] = "parallel converted";
// System.out.println(methods[6]);
time = System.currentTimeMillis();
{
img.forEach(PixelConvertingSpliterator.getDoubleArrayConverter(), true, arr-> {
double luminance = arr[0]*0.2126 + arr[1]*0.7152 + arr[2]*0.0722;
double lumDif = luminance-contrastLum;
arr[0] += lumDif*contrastIntensity;
arr[1] += lumDif*contrastIntensity;
arr[2] += lumDif*contrastIntensity;
});
}
times[6] += System.currentTimeMillis()-time;
imgBackup.copyArea(0, 0, img.getWidth(), img.getHeight(), img, 0, 0);


}
}

System.out.println("-----Results-----");
// results
for(int i = 0; i < times.length; i++){
System.out.format("%s:%s%n", methods[i], times[i]/numLoops);
System.out.println("-----Results--"+Arrays.toString(probsize)+"-----");
// results
for(int i = 0; i < times.length; i++){
System.out.format("%s:%s%n", methods[i], times[i]/numLoops);
}
}

}
Expand Down
Loading

0 comments on commit 9ef45f4

Please sign in to comment.