< prev index next >

test/jdk/jdk/incubator/vector/templates/Perf-Scalar-Unary-Masked-op.template

Print this page
rev 55606 : 8221812: Fine-tune jmh test for vector api
Summary: To compare performance of vector api and auto vectorization, vector
api and scalar test cases are updated to keep aligned.
Reviewed-by: duke
   1 
   2     @Benchmark
   3     public Object [[TEST]][[TEST_TYPE]][[OP_NAME]]() {
   4         $type$[] as = fa.apply(size);
   5         $type$[] rs = fr.apply(size);
   6         boolean[] ms = fm.apply(size);
   7 

   8         for (int i = 0; i < as.length; i++) {
   9             $type$ a = as[i];
  10             boolean m = ms[i % ms.length];
  11             rs[i] = (m ? ($type$)([[TEST_OP]]) : a);
  12         }

  13 
  14         return rs;
  15     }
   1 
   2     @Benchmark
   3     public void [[TEST]][[TEST_TYPE]][[OP_NAME]](Blackhole bh) {
   4         $type$[] as = fa.apply(size);
   5         $type$[] rs = fr.apply(size);
   6         boolean[] ms = fm.apply(size);
   7 
   8         for (int ic = 0; ic < INVOC_COUNT; ic++) {
   9             for (int i = 0; i < as.length; i++) {
  10                 $type$ a = as[i];
  11                 boolean m = ms[i % ms.length];
  12                 rs[i] = (m ? ($type$)([[TEST_OP]]) : a);
  13             }
  14         }
  15 
  16         bh.consume(rs);
  17     }
< prev index next >