jdk/test/java/beans/Performance/Test7184799.java
author malenkov
Mon, 30 Jul 2012 13:35:10 +0400
changeset 13356 89a34c00fd8c
child 20094 462e588b8284
permissions -rw-r--r--
7187618: PropertyDescriptor Performance Slow Reviewed-by: rupashka
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13356
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
     1
/*
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
     4
 *
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
     8
 *
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    13
 * accompanied this code).
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    14
 *
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    18
 *
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    21
 * questions.
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    22
 */
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    23
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    24
/*
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    25
 * @test
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    26
 * @bug 7184799
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    27
 * @summary Tests just a benchmark of Introspector.getBeanInfo(Class) performance
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    28
 * @author Sergey Malenkov
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    29
 * @run main/manual Test7184799
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    30
 */
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    31
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    32
import java.beans.Introspector;
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    33
import java.util.*;
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    34
import java.util.concurrent.ConcurrentHashMap;
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    35
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    36
public class Test7184799 {
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    37
    private static final Class[] TYPES = {
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    38
            Class.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    39
            String.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    40
            Character.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    41
            Boolean.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    42
            Byte.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    43
            Short.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    44
            Integer.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    45
            Long.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    46
            Float.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    47
            Double.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    48
            Collection.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    49
            Set.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    50
            HashSet.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    51
            TreeSet.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    52
            LinkedHashSet.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    53
            Map.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    54
            HashMap.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    55
            TreeMap.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    56
            LinkedHashMap.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    57
            WeakHashMap.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    58
            ConcurrentHashMap.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    59
            Dictionary.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    60
            Exception.class,
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    61
    };
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    62
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    63
    public static void main(String[] args) throws Exception {
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    64
        long time = System.nanoTime();
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    65
        for (Class type : TYPES) {
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    66
            Introspector.getBeanInfo(type);
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    67
        }
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    68
        time -= System.nanoTime();
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    69
        System.out.println("Time (ms): " + (-time / 1000000));
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    70
    }
89a34c00fd8c 7187618: PropertyDescriptor Performance Slow
malenkov
parents:
diff changeset
    71
}