Skip to content

Commit 88fc364

Browse files
committed
refactor: standardize benchmark to fastimage.benchmark.Benchmark and update run-benchmark.bat
1 parent d460417 commit 88fc364

3 files changed

Lines changed: 70 additions & 46 deletions

File tree

examples/Benchmark/pom.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
<uberjar.name>benchmarks</uberjar.name>
1616
</properties>
1717

18+
<repositories>
19+
<repository>
20+
<id>jitpack.io</id>
21+
<url>https://jitpack.io</url>
22+
</repository>
23+
</repositories>
24+
1825
<dependencies>
1926
<dependency>
2027
<groupId>com.github.andrestubbe</groupId>
@@ -24,7 +31,7 @@
2431
<dependency>
2532
<groupId>com.github.andrestubbe</groupId>
2633
<artifactId>FastSIMD</artifactId>
27-
<version>0.1.3</version>
34+
<version>main-SNAPSHOT</version>
2835
</dependency>
2936
<dependency>
3037
<groupId>org.openjdk.jmh</groupId>

examples/Benchmark/src/main/java/fastimage/benchmark/JMH_Image.java renamed to examples/Benchmark/src/main/java/fastimage/benchmark/Benchmark.java

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
package fastimage.benchmark;
2-
3-
import fastimage.FastImage;
4-
import org.openjdk.jmh.annotations.*;
5-
6-
import java.util.concurrent.TimeUnit;
7-
8-
@BenchmarkMode(Mode.Throughput)
9-
@OutputTimeUnit(TimeUnit.SECONDS)
10-
@State(Scope.Thread)
11-
@Warmup(iterations = 1, time = 1)
12-
@Measurement(iterations = 2, time = 1)
13-
@Fork(1)
14-
public class JMH_Image {
15-
16-
private FastImage srcImage;
17-
18-
@Setup
19-
public void setup() {
20-
srcImage = FastImage.create(1920, 1080);
21-
}
22-
23-
@Benchmark
24-
public Object benchmarkFastImageResize() {
25-
return srcImage.resize(1280, 720);
26-
}
27-
28-
@Benchmark
29-
public Object benchmarkFastImageKawaseBlur() {
30-
return srcImage.blurKawase(3.0f, 2);
31-
}
32-
}
1+
package fastimage.benchmark;
2+
3+
import fastimage.FastImage;
4+
import org.openjdk.jmh.annotations.*;
5+
6+
import java.util.concurrent.TimeUnit;
7+
8+
@BenchmarkMode(Mode.Throughput)
9+
@OutputTimeUnit(TimeUnit.MILLISECONDS)
10+
@State(Scope.Thread)
11+
@Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS)
12+
@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
13+
@Fork(1)
14+
public class Benchmark {
15+
16+
private FastImage srcImage;
17+
18+
@Setup
19+
public void setup() {
20+
srcImage = FastImage.create(1920, 1080);
21+
}
22+
23+
@org.openjdk.jmh.annotations.Benchmark
24+
public Object benchmarkFastImageResize() {
25+
return srcImage.resize(1280, 720);
26+
}
27+
28+
@org.openjdk.jmh.annotations.Benchmark
29+
public Object benchmarkFastImageKawaseBlur() {
30+
return srcImage.blurKawase(3.0f, 2);
31+
}
32+
}

run-benchmark.bat

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
1-
@echo off
2-
echo Building Main Project...
3-
call mvn clean install -DskipTests -q
4-
5-
echo Building Benchmark Uber-JAR...
6-
cd examples\Benchmark
7-
call mvn clean package -DskipTests -q
8-
9-
echo Running JMH Benchmarks...
10-
java -jar target\benchmarks.jar -f 1 -i 2 -wi 1 -w 1s -r 1s
11-
12-
cd ..\..
13-
pause
1+
@echo off
2+
setlocal
3+
chcp 65001 > nul
4+
cd /d "%~dp0"
5+
set "MAVEN_OPTS=--enable-native-access=ALL-UNNAMED --sun-misc-unsafe-memory-access=allow -Dorg.slf4j.simpleLogger.defaultLogLevel=warn"
6+
7+
echo ===================================================
8+
echo Building FastImage ^& JMH Benchmarks Uber-Jar
9+
echo ===================================================
10+
11+
call mvn -q clean install -DskipTests 2>nul
12+
if %ERRORLEVEL% NEQ 0 (
13+
echo [ERROR] FastImage install failed!
14+
pause
15+
exit /b %ERRORLEVEL%
16+
)
17+
18+
cd examples\Benchmark
19+
call mvn -q clean package 2>nul
20+
if %ERRORLEVEL% NEQ 0 (
21+
echo [ERROR] Benchmark packaging failed!
22+
pause
23+
exit /b %ERRORLEVEL%
24+
)
25+
26+
echo ===================================================
27+
echo Running JMH Benchmarks (Throughput: ops/ms)
28+
echo ===================================================
29+
java --enable-native-access=ALL-UNNAMED --sun-misc-unsafe-memory-access=allow "-Djava.library.path=..\..\build;build;src\main\resources\native" -jar target\benchmarks.jar -f 1 -wi 2 -i 3 -tu ms -bm thrpt
30+
pause

0 commit comments

Comments
 (0)