< prev index next >

test/java/lang/Class/TypeCheckMicroBenchmark.java

Print this page
rev 10985 : [mq]: 8061549


 165             new Job("toArray(T[])") { void work() {
 166                 Object[] a = new Integer[0];
 167                 for (int i = 0; i < iterations; i++) {
 168                     try { list.toArray(a); }
 169                     catch (ArrayStoreException ase) {
 170                         throw new ClassCastException(); }}}},
 171             new Job("isInstance") { void work() {
 172                 for (int i = 0; i < iterations; i++) {
 173                     for (Object x : list.toArray())
 174                         if (! (x != null && klazz.isInstance(x)))
 175                             throw new ClassCastException(); }}},
 176             new Job("Class.cast") { void work() {
 177                 for (int i = 0; i < iterations; i++) {
 178                     for (Object x : list.toArray())
 179                         klazz.cast(x); }}},
 180             new Job("write into array") { void work() {
 181                 Object[] a = new Integer[1];
 182                 for (int i = 0; i < iterations; i++) {
 183                     for (Object x : list.toArray()) {
 184                         try { a[0] = x; }
 185                         catch (ArrayStoreException _) {
 186                             throw new ClassCastException(); }}}}},
 187             new Job("write into dynamic array") { void work() {
 188                 for (int i = 0; i < iterations; i++) {
 189                     for (Object x : list.toArray()) {
 190                         Object[] a = (Object[])
 191                             java.lang.reflect.Array.newInstance(klazz, 1);
 192                         try { a[0] = x; }
 193                         catch (ArrayStoreException _) {
 194                             throw new ClassCastException(); }}}}}
 195         };
 196 
 197         time(filter(filter, jobs));
 198     }
 199 }


 165             new Job("toArray(T[])") { void work() {
 166                 Object[] a = new Integer[0];
 167                 for (int i = 0; i < iterations; i++) {
 168                     try { list.toArray(a); }
 169                     catch (ArrayStoreException ase) {
 170                         throw new ClassCastException(); }}}},
 171             new Job("isInstance") { void work() {
 172                 for (int i = 0; i < iterations; i++) {
 173                     for (Object x : list.toArray())
 174                         if (! (x != null && klazz.isInstance(x)))
 175                             throw new ClassCastException(); }}},
 176             new Job("Class.cast") { void work() {
 177                 for (int i = 0; i < iterations; i++) {
 178                     for (Object x : list.toArray())
 179                         klazz.cast(x); }}},
 180             new Job("write into array") { void work() {
 181                 Object[] a = new Integer[1];
 182                 for (int i = 0; i < iterations; i++) {
 183                     for (Object x : list.toArray()) {
 184                         try { a[0] = x; }
 185                         catch (ArrayStoreException unused) {
 186                             throw new ClassCastException(); }}}}},
 187             new Job("write into dynamic array") { void work() {
 188                 for (int i = 0; i < iterations; i++) {
 189                     for (Object x : list.toArray()) {
 190                         Object[] a = (Object[])
 191                             java.lang.reflect.Array.newInstance(klazz, 1);
 192                         try { a[0] = x; }
 193                         catch (ArrayStoreException unused) {
 194                             throw new ClassCastException(); }}}}}
 195         };
 196 
 197         time(filter(filter, jobs));
 198     }
 199 }
< prev index next >