jdk/src/share/demo/java2d/J2DBench/src/j2dbench/Result.java
author ohair
Tue, 28 Dec 2010 15:53:50 -0800
changeset 7668 d4a77089c587
parent 7233 e560b64571c7
child 10292 ed7db6a12c2a
permissions -rw-r--r--
6962318: Update copyright year Reviewed-by: xdono
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 7233
diff changeset
     2
 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * Redistribution and use in source and binary forms, with or without
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * modification, are permitted provided that the following conditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *   - Redistributions of source code must retain the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *     notice, this list of conditions and the following disclaimer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 *   - Redistributions in binary form must reproduce the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 *     notice, this list of conditions and the following disclaimer in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 *     documentation and/or other materials provided with the distribution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    15
 *   - Neither the name of Oracle nor the names of its
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *     contributors may be used to endorse or promote products derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 *     from this software without specific prior written permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
package j2dbench;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.Hashtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.Enumeration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.io.PrintWriter;
7233
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    38
import java.util.HashMap;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
public class Result {
7233
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    41
    public static final int RATE_UNKNOWN    = 0;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    42
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    43
    public static final int WORK_OPS        = 1;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    44
    public static final int WORK_UNITS      = 2;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    45
    public static final int WORK_THOUSANDS  = 4;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    46
    public static final int WORK_MILLIONS   = 6;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    47
    public static final int WORK_AUTO       = 8;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    48
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    49
    public static final int TIME_SECONDS    = 10;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    50
    public static final int TIME_MILLIS     = 11;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    51
    public static final int TIME_MICROS     = 12;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    52
    public static final int TIME_NANOS      = 13;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    53
    public static final int TIME_AUTO       = 14;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    54
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    55
    static Group resultoptroot;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    56
    static Option.ObjectChoice timeOpt;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    57
    static Option.ObjectChoice workOpt;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    58
    static Option.ObjectChoice rateOpt;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    59
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    60
    public static void init() {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    61
        resultoptroot = new Group(TestEnvironment.globaloptroot,
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    62
                                  "results", "Result Options");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
7233
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    64
        String workStrings[] = {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    65
            "units",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    66
            "kilounits",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    67
            "megaunits",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    68
            "autounits",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    69
            "ops",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    70
            "kiloops",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    71
            "megaops",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    72
            "autoops",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    73
        };
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    74
        String workDescriptions[] = {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    75
            "Test Units",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    76
            "Thousands of Test Units",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    77
            "Millions of Test Units",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    78
            "Auto-scaled Test Units",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    79
            "Operations",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    80
            "Thousands of Operations",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    81
            "Millions of Operations",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    82
            "Auto-scaled Operations",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    83
        };
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    84
        Integer workObjects[] = {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    85
            new Integer(WORK_UNITS),
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    86
            new Integer(WORK_THOUSANDS),
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    87
            new Integer(WORK_MILLIONS),
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    88
            new Integer(WORK_AUTO),
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    89
            new Integer(WORK_OPS | WORK_UNITS),
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    90
            new Integer(WORK_OPS | WORK_THOUSANDS),
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    91
            new Integer(WORK_OPS | WORK_MILLIONS),
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    92
            new Integer(WORK_OPS | WORK_AUTO),
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    93
        };
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    94
        workOpt = new Option.ObjectChoice(resultoptroot,
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    95
                                          "workunits", "Work Units",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    96
                                          workStrings, workObjects,
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    97
                                          workStrings, workDescriptions,
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    98
                                          0);
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
    99
        String timeStrings[] = {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   100
            "sec",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   101
            "msec",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   102
            "usec",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   103
            "nsec",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   104
            "autosec",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   105
        };
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   106
        String timeDescriptions[] = {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   107
            "Seconds",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   108
            "Milliseconds",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   109
            "Microseconds",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   110
            "Nanoseconds",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   111
            "Auto-scaled seconds",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   112
        };
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   113
        Integer timeObjects[] = {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   114
            new Integer(TIME_SECONDS),
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   115
            new Integer(TIME_MILLIS),
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   116
            new Integer(TIME_MICROS),
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   117
            new Integer(TIME_NANOS),
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   118
            new Integer(TIME_AUTO),
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   119
        };
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   120
        timeOpt = new Option.ObjectChoice(resultoptroot,
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   121
                                          "timeunits", "Time Units",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   122
                                          timeStrings, timeObjects,
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   123
                                          timeStrings, timeDescriptions,
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   124
                                          0);
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   125
        String rateStrings[] = {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   126
            "unitspersec",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   127
            "secsperunit",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   128
        };
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   129
        String rateDescriptions[] = {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   130
            "Work units per Time",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   131
            "Time units per Work",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   132
        };
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   133
        Boolean rateObjects[] = {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   134
            Boolean.FALSE,
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   135
            Boolean.TRUE,
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   136
        };
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   137
        rateOpt = new Option.ObjectChoice(resultoptroot,
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   138
                                          "ratio", "Rate Ratio",
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   139
                                          rateStrings, rateObjects,
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   140
                                          rateStrings, rateDescriptions,
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   141
                                          0);
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   142
    }
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   143
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   144
    public static boolean isTimeUnit(int unit) {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   145
        return (unit >= TIME_SECONDS && unit <= TIME_AUTO);
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   146
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
7233
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   148
    public static boolean isWorkUnit(int unit) {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   149
        return (unit >= WORK_OPS && unit <= (WORK_AUTO | WORK_OPS));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   150
    }
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   151
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   152
    public static String parseRateOpt(String opt) {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   153
        int timeScale = timeOpt.getIntValue();
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   154
        int workScale = workOpt.getIntValue();
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   155
        boolean invertRate = rateOpt.getBooleanValue();
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   156
        int divindex = opt.indexOf('/');
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   157
        if (divindex < 0) {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   158
            int unit = parseUnit(opt);
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   159
            if (isTimeUnit(unit)) {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   160
                timeScale = unit;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   161
            } else if (isWorkUnit(unit)) {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   162
                workScale = unit;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   163
            } else {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   164
                return "Bad unit: "+opt;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   165
            }
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   166
        } else {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   167
            int unit1 = parseUnit(opt.substring(0,divindex));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   168
            int unit2 = parseUnit(opt.substring(divindex+1));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   169
            if (isTimeUnit(unit1)) {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   170
                if (isWorkUnit(unit2)) {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   171
                    timeScale = unit1;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   172
                    workScale = unit2;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   173
                    invertRate = true;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   174
                } else if (isTimeUnit(unit2)) {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   175
                    return "Both time units: "+opt;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   176
                } else {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   177
                    return "Bad denominator: "+opt;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   178
                }
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   179
            } else if (isWorkUnit(unit1)) {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   180
                if (isWorkUnit(unit2)) {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   181
                    return "Both work units: "+opt;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   182
                } else if (isTimeUnit(unit2)) {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   183
                    timeScale = unit2;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   184
                    workScale = unit1;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   185
                    invertRate = false;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   186
                } else {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   187
                    return "Bad denominator: "+opt;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   188
                }
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   189
            } else {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   190
                return "Bad numerator: "+opt;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   191
            }
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   192
        }
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   193
        timeOpt.setValue(timeScale);
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   194
        workOpt.setValue(workScale);
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   195
        rateOpt.setValue(invertRate);
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   196
        return null;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   197
    }
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   198
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   199
    private static HashMap unitMap;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   200
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   201
    static {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   202
        unitMap = new HashMap();
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   203
        unitMap.put("U",  new Integer(WORK_UNITS));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   204
        unitMap.put("M",  new Integer(WORK_MILLIONS));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   205
        unitMap.put("K",  new Integer(WORK_THOUSANDS));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   206
        unitMap.put("A",  new Integer(WORK_AUTO));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   207
        unitMap.put("MU", new Integer(WORK_MILLIONS));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   208
        unitMap.put("KU", new Integer(WORK_THOUSANDS));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   209
        unitMap.put("AU", new Integer(WORK_AUTO));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   210
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   211
        unitMap.put("O",  new Integer(WORK_UNITS | WORK_OPS));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   212
        unitMap.put("NO", new Integer(WORK_UNITS | WORK_OPS));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   213
        unitMap.put("MO", new Integer(WORK_MILLIONS | WORK_OPS));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   214
        unitMap.put("KO", new Integer(WORK_THOUSANDS | WORK_OPS));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   215
        unitMap.put("AO", new Integer(WORK_AUTO | WORK_OPS));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   216
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   217
        unitMap.put("s",  new Integer(TIME_SECONDS));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   218
        unitMap.put("m",  new Integer(TIME_MILLIS));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   219
        unitMap.put("u",  new Integer(TIME_MICROS));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   220
        unitMap.put("n",  new Integer(TIME_NANOS));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   221
        unitMap.put("a",  new Integer(TIME_AUTO));
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   222
    }
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   223
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   224
    public static int parseUnit(String c) {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   225
        Integer u = (Integer) unitMap.get(c);
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   226
        if (u != null) {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   227
            return u.intValue();
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   228
        }
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   229
        return RATE_UNKNOWN;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   230
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    String unitname = "unit";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    Test test;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    int repsPerRun;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    int unitsPerRep;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    Vector times;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    Hashtable modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    Throwable error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    public Result(Test test) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        this.test = test;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        this.repsPerRun = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        this.unitsPerRep = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        times = new Vector();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    public void setReps(int reps) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        this.repsPerRun = reps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    public void setUnits(int units) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        this.unitsPerRep = units;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    public void setUnitName(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        this.unitname = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    public void addTime(long time) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        if (J2DBench.printresults.isEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            System.out.println(test+" took "+time+"ms for "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                               getRepsPerRun()+" reps");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        times.addElement(new Long(time));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    public void setError(Throwable t) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        this.error = t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    public void setModifiers(Hashtable modifiers) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        this.modifiers = modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    public Throwable getError() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        return error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    public int getRepsPerRun() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        return repsPerRun;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    public int getUnitsPerRep() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        return unitsPerRep;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    public long getUnitsPerRun() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        return ((long) getRepsPerRun()) * ((long) getUnitsPerRep());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    public Hashtable getModifiers() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        return modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    public long getNumRuns() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        return times.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    public long getTime(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        return ((Long) times.elementAt(index)).longValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    public double getRepsPerSecond(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        return (getRepsPerRun() * 1000.0) / getTime(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    public double getUnitsPerSecond(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        return (getUnitsPerRun() * 1000.0) / getTime(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    public long getTotalReps() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        return getRepsPerRun() * getNumRuns();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    public long getTotalUnits() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        return getUnitsPerRun() * getNumRuns();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    public long getTotalTime() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        long totalTime = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        for (int i = 0; i < times.size(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
            totalTime += getTime(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        return totalTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    public double getAverageRepsPerSecond() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        return (getTotalReps() * 1000.0) / getTotalTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    public double getAverageUnitsPerSecond() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        return (getTotalUnits() * 1000.0) / getTotalTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    public String getAverageString() {
7233
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   336
        int timeScale = timeOpt.getIntValue();
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   337
        int workScale = workOpt.getIntValue();
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   338
        boolean invertRate = rateOpt.getBooleanValue();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        double time = getTotalTime();
7233
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   340
        String timeprefix = "";
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   341
        switch (timeScale) {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   342
        case TIME_AUTO:
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   343
        case TIME_SECONDS:
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   344
            time /= 1000;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   345
            break;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   346
        case TIME_MILLIS:
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   347
            timeprefix = "m";
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   348
            break;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   349
        case TIME_MICROS:
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   350
            time *= 1000.0;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   351
            timeprefix = "u";
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   352
            break;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   353
        case TIME_NANOS:
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   354
            time *= 1000000.0;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   355
            timeprefix = "n";
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   356
            break;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   357
        }
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   358
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   359
        String workprefix = "";
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   360
        boolean isOps = (workScale & WORK_OPS) != 0;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   361
        String workname = isOps ? "op" : unitname;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   362
        double work = isOps ? getTotalReps() : getTotalUnits();
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   363
        switch (workScale & (~WORK_OPS)) {
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   364
        case WORK_AUTO:
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   365
        case WORK_UNITS:
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   366
            break;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   367
        case WORK_THOUSANDS:
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   368
            work /= 1000.0;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   369
            workprefix = "K";
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   370
            break;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   371
        case WORK_MILLIONS:
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   372
            work /= 1000000.0;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   373
            workprefix = "M";
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   374
            break;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   375
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        if (invertRate) {
7233
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   377
            double rate = time / work;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   378
            if (timeScale == TIME_AUTO) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                if (rate < 1.0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                    rate *= 1000.0;
7233
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   381
                    timeprefix = "m";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                    if (rate < 1.0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                        rate *= 1000.0;
7233
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   384
                        timeprefix = "u";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                        if (rate < 1.0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                            rate *= 1000.0;
7233
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   387
                            timeprefix = "n";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            }
7233
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   392
            return rate+" "+timeprefix+"secs/"+workprefix+workname;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        } else {
7233
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   394
            double rate = work / time;
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   395
            if (workScale == WORK_AUTO) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                if (rate > 1000.0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                    rate /= 1000.0;
7233
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   398
                    workprefix = "K";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                    if (rate > 1000.0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                        rate /= 1000.0;
7233
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   401
                        workprefix = "M";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            }
7233
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   405
            return rate+" "+workprefix+workname+"s/"+timeprefix+"sec";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    public void summarize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        if (error != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            System.out.println(test+" skipped due to "+error);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            error.printStackTrace(System.out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            System.out.println(test+" averaged "+getAverageString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        if (true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            Enumeration enum_ = modifiers.keys();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            System.out.print("    with");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            String sep = " ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            while (enum_.hasMoreElements()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                Modifier mod = (Modifier) enum_.nextElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                Object v = modifiers.get(mod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                System.out.print(sep);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                System.out.print(mod.getAbbreviatedModifierDescription(v));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                sep = ", ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            System.out.println();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    public void write(PrintWriter pw) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        pw.println("  <result "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                   "num-reps=\""+getRepsPerRun()+"\" "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                   "num-units=\""+getUnitsPerRep()+"\" "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                   "name=\""+test.getTreeName()+"\">");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        Enumeration enum_ = modifiers.keys();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        while (enum_.hasMoreElements()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            Modifier mod = (Modifier) enum_.nextElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
            Object v = modifiers.get(mod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            String val = mod.getModifierValueName(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            pw.println("    <option "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                       "key=\""+mod.getTreeName()+"\" "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                       "value=\""+val+"\"/>");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        for (int i = 0; i < getNumRuns(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            pw.println("    <time value=\""+getTime(i)+"\"/>");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        pw.println("  </result>");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
}