summaryrefslogtreecommitdiff
path: root/src/main/java/org/linaro/benchmarks/TestRGBToCmyk.java
diff options
context:
space:
mode:
authorYang Zhang <yang.zhang@linaro.org>2016-09-23 11:17:15 +0800
committerNingsheng Jian <ningsheng.jian@linaro.org>2016-11-02 04:15:17 +0000
commitead42d0823f9921041dbd44882ed2062c0a9f74f (patch)
tree0963333f8726b2acd8393224f4a84695f2db096f /src/main/java/org/linaro/benchmarks/TestRGBToCmyk.java
parent7de7b54b6f037e54fa2ce5d3a2939357a2e2ebb7 (diff)
Add samples to measure vector ldn/stn performance
Add the test cases as follows: 1. 2D vector add and mul for int/short 2. 3D vector add and mul for int/short 3. 4D vector add and mul for int/short 4. RGB To Cmyk for ld3/st4 Change-Id: I68079a8bb2f50bf0d07c3a382a1d7208b95ff9f7
Diffstat (limited to 'src/main/java/org/linaro/benchmarks/TestRGBToCmyk.java')
-rw-r--r--src/main/java/org/linaro/benchmarks/TestRGBToCmyk.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/main/java/org/linaro/benchmarks/TestRGBToCmyk.java b/src/main/java/org/linaro/benchmarks/TestRGBToCmyk.java
new file mode 100644
index 0000000..b9bc897
--- /dev/null
+++ b/src/main/java/org/linaro/benchmarks/TestRGBToCmyk.java
@@ -0,0 +1,53 @@
+package org.linaro.benchmarks;
+
+import org.openjdk.jmh.annotations.*;
+import java.util.concurrent.TimeUnit;
+
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.MICROSECONDS)
+@State(Scope.Benchmark)
+
+public class TestRGBToCmyk
+{
+ static final int LENGTH = 256 * 1024;
+ static byte input[] = new byte[LENGTH*3];
+ static byte output[] = new byte[LENGTH*4];
+
+ public static void TestRGBToCmykInit()
+ {
+ for (int i = 0; i < LENGTH*3; i++) {
+ input[i] = (byte)i;
+ }
+ }
+
+ public static void RGBToCmyk(byte[] rgb, byte[] cmyk, int cnt)
+ {
+ int i;
+ int c, m, y, k;
+ for (i = 0; i < cnt; i++) {
+ /* calculate complementary colors */
+ c = 255 - rgb[i*3];
+ m = 255 - rgb[i*3+1];
+ y = 255 - rgb[i*3+2];
+ /* find the black level k */
+ k = Math.min(Math.min(c, m), y);
+ /* correct complementary color lever based on k */
+ cmyk[i*4] = (byte)(c - k);
+ cmyk[i*4+1] = (byte)(m - k);
+ cmyk[i*4+2] = (byte)(y - k);
+ cmyk[i*4+3] = (byte)(k);
+ }
+ }
+
+ @Setup
+ public void setup()
+ {
+ TestRGBToCmykInit();
+ }
+
+ @Benchmark
+ public void testRGBToCmyk() {
+ RGBToCmyk(input, output, LENGTH);
+ }
+
+}