TestAESMain.java revision 12158:0fe2815ffa74
1/* 2 * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24/** 25 * @test 26 * @bug 7184394 27 * @key stress 28 * @summary add intrinsics to use AES instructions 29 * @library /test/lib / 30 * @modules java.base/jdk.internal.misc 31 * java.management 32 * 33 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC 34 * compiler.codegen.aes.TestAESMain 35 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 36 * compiler.codegen.aes.TestAESMain 37 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencOutputOffset=1 38 * compiler.codegen.aes.TestAESMain 39 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DdecOutputOffset=1 40 * compiler.codegen.aes.TestAESMain 41 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 -DencOutputOffset=1 42 * compiler.codegen.aes.TestAESMain 43 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 44 * compiler.codegen.aes.TestAESMain 45 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding -DmsgSize=640 46 * compiler.codegen.aes.TestAESMain 47 * 48 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB 49 * compiler.codegen.aes.TestAESMain 50 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 51 * compiler.codegen.aes.TestAESMain 52 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencOutputOffset= 53 * compiler.codegen.aes.TestAESMain 54 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DdecOutputOffset=1 55 * compiler.codegen.aes.TestAESMain 56 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 -DencOutputOffset=1 57 * compiler.codegen.aes.TestAESMain 58 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 59 * compiler.codegen.aes.TestAESMain 60 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding -DmsgSize=640 61 * compiler.codegen.aes.TestAESMain 62 * 63 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM 64 * compiler.codegen.aes.TestAESMain 65 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DencInputOffset=1 66 * compiler.codegen.aes.TestAESMain 67 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DencOutputOffset=1 68 * compiler.codegen.aes.TestAESMain 69 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DdecOutputOffset=1 70 * compiler.codegen.aes.TestAESMain 71 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DencInputOffset=1 -DencOutputOffset=1 72 * compiler.codegen.aes.TestAESMain 73 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 74 * compiler.codegen.aes.TestAESMain 75 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding -DmsgSize=640 76 * compiler.codegen.aes.TestAESMain 77 * 78 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR 79 * compiler.codegen.aes.TestAESMain 80 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 81 * compiler.codegen.aes.TestAESMain 82 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencOutputOffset=1 83 * compiler.codegen.aes.TestAESMain 84 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DdecOutputOffset=1 85 * compiler.codegen.aes.TestAESMain 86 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 -DencOutputOffset=1 87 * compiler.codegen.aes.TestAESMain 88 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 89 * compiler.codegen.aes.TestAESMain 90 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding -DmsgSize=640 91 * compiler.codegen.aes.TestAESMain 92 * 93 * @author Tom Deneau 94 */ 95 96package compiler.codegen.aes; 97 98public class TestAESMain { 99 public static void main(String[] args) { 100 int iters = (args.length > 0 ? Integer.valueOf(args[0]) : 1000000); 101 int warmupIters = (args.length > 1 ? Integer.valueOf(args[1]) : 20000); 102 System.out.println(iters + " iterations"); 103 TestAESEncode etest = new TestAESEncode(); 104 etest.prepare(); 105 // warm-up 106 System.out.println("Starting encryption warm-up"); 107 for (int i = 0; i < warmupIters; i++) { 108 etest.run(); 109 } 110 System.out.println("Finished encryption warm-up"); 111 long start = System.nanoTime(); 112 for (int i = 0; i < iters; i++) { 113 etest.run(); 114 } 115 long end = System.nanoTime(); 116 System.out.println("TestAESEncode runtime was " + (double) ((end - start) / 1000000.0) + " ms"); 117 118 TestAESDecode dtest = new TestAESDecode(); 119 dtest.prepare(); 120 // warm-up 121 System.out.println("Starting decryption warm-up"); 122 for (int i = 0; i < warmupIters; i++) { 123 dtest.run(); 124 } 125 System.out.println("Finished decryption warm-up"); 126 start = System.nanoTime(); 127 for (int i = 0; i < iters; i++) { 128 dtest.run(); 129 } 130 end = System.nanoTime(); 131 System.out.println("TestAESDecode runtime was " + (double) ((end - start) / 1000000.0) + " ms"); 132 } 133} 134