test/jdk/sun/nio/cs/StrCodingBenchmark.java
author jiangli
Wed, 27 Sep 2017 17:55:20 -0400
changeset 47548 664b9d44db74
parent 47216 71c04702a3d5
permissions -rw-r--r--
8068314: "Java fields that are currently set during shared space dumping" comment is incorrect Summary: CDS dump time should also initialize preallocated out_of_memory error messages. Reviewed-by: iklam, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2294
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 13257
diff changeset
     2
 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
2294
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
     4
 *
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
     8
 *
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    13
 * accompanied this code).
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    14
 *
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2294
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2294
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2294
diff changeset
    21
 * questions.
2294
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    22
 */
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    23
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    24
import java.util.*;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    25
import java.nio.*;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    26
import java.nio.charset.*;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    27
import java.util.concurrent.*;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    28
import java.util.regex.Pattern;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    29
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    30
/**
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    31
 * Usage: java StringCodingBenchmark
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    32
 * [-Diterations=N] [-Dsize=N] [-Dsubsize=N] [-Dmaxchar=N]
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    33
 * [-Dfilter=REGEXP] [-DSecurityManager=true]
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    34
 */
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    35
public class StrCodingBenchmark {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    36
    abstract static class Job {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    37
        private final String name;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    38
        public Job(String name) { this.name = name; }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    39
        public String name() { return name; }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    40
        public abstract void work() throws Throwable;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    41
    }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    42
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    43
    private static void collectAllGarbage() {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    44
        final java.util.concurrent.CountDownLatch drained
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    45
            = new java.util.concurrent.CountDownLatch(1);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    46
        try {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    47
            System.gc();        // enqueue finalizable objects
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    48
            new Object() { protected void finalize() {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    49
                drained.countDown(); }};
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    50
            System.gc();        // enqueue detector
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    51
            drained.await();    // wait for finalizer queue to drain
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    52
            System.gc();        // cleanup finalized objects
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    53
        } catch (InterruptedException e) { throw new Error(e); }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    54
    }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    55
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    56
    /**
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    57
     * Runs each job for long enough that all the runtime compilers
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    58
     * have had plenty of time to warm up, i.e. get around to
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    59
     * compiling everything worth compiling.
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    60
     * Returns array of average times per job per run.
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    61
     */
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    62
    public static long[] time0(Job ... jobs) throws Throwable {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    63
        //final long warmupNanos = 10L * 1000L * 1000L * 1000L;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    64
        final long warmupNanos = 100L * 100L;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    65
        long[] nanoss = new long[jobs.length];
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    66
        for (int i = 0; i < jobs.length; i++) {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    67
            collectAllGarbage();
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    68
            long t0 = System.nanoTime();
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    69
            long t;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    70
            int j = 0;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    71
            do { jobs[i].work(); j++; }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    72
            while ((t = System.nanoTime() - t0) < warmupNanos);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    73
            nanoss[i] = t/j;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    74
        }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    75
        return nanoss;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    76
    }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    77
13257
5cf4ff2cbb37 7183053: Optimize DoubleByte charset for String.getBytes()/new String(byte[])
sherman
parents: 5506
diff changeset
    78
    public static long[] time(Job ... jobs) throws Throwable {
2294
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    79
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    80
        long[] warmup = time0(jobs); // Warm up run
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    81
        long[] nanoss = time0(jobs); // Real timing run
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    82
        long[] milliss = new long[jobs.length];
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    83
        double[] ratios = new double[jobs.length];
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    84
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    85
        final String nameHeader   = "Method";
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    86
        final String millisHeader = "Millis";
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    87
        final String ratioHeader  = "Ratio";
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    88
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    89
        int nameWidth   = nameHeader.length();
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    90
        int millisWidth = millisHeader.length();
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    91
        int ratioWidth  = ratioHeader.length();
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    92
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    93
        for (int i = 0; i < jobs.length; i++) {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    94
            nameWidth = Math.max(nameWidth, jobs[i].name().length());
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    95
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    96
            milliss[i] = nanoss[i]/(1000L * 1000L);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    97
            millisWidth = Math.max(millisWidth,
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    98
                                   String.format("%d", milliss[i]).length());
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
    99
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   100
            ratios[i] = (double) nanoss[i] / (double) nanoss[0];
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   101
            ratioWidth = Math.max(ratioWidth,
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   102
                                  String.format("%.3f", ratios[i]).length());
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   103
        }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   104
        String format = String.format("%%-%ds %%%dd %n",
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   105
                                      nameWidth, millisWidth);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   106
        String headerFormat = String.format("%%-%ds %%%ds%n",
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   107
                                            nameWidth, millisWidth);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   108
        System.out.printf(headerFormat, "Method", "Millis");
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   109
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   110
        // Print out absolute and relative times, calibrated against first job
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   111
        for (int i = 0; i < jobs.length; i++)
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   112
            System.out.printf(format, jobs[i].name(), milliss[i], ratios[i]);
13257
5cf4ff2cbb37 7183053: Optimize DoubleByte charset for String.getBytes()/new String(byte[])
sherman
parents: 5506
diff changeset
   113
        return milliss;
2294
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   114
    }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   115
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   116
    public static Job[] filter(Pattern filter, Job[] jobs) {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   117
        if (filter == null) return jobs;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   118
        Job[] newJobs = new Job[jobs.length];
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   119
        int n = 0;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   120
        for (Job job : jobs)
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   121
            if (filter.matcher(job.name()).find())
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   122
                newJobs[n++] = job;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   123
        // Arrays.copyOf not available in JDK 5
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   124
        Job[] ret = new Job[n];
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   125
        System.arraycopy(newJobs, 0, ret, 0, n);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   126
        return ret;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   127
    }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   128
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   129
    static class PermissiveSecurityManger extends SecurityManager {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   130
        @Override public void checkPermission(java.security.Permission p) {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   131
        }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   132
    }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   133
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   134
    public static void main(String[] args) throws Throwable {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   135
        final int itrs = Integer.getInteger("iterations", 100000);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   136
        final int size       = Integer.getInteger("size", 2048);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   137
        final int subsize    = Integer.getInteger("subsize", 128);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   138
        final int maxchar    = Integer.getInteger("maxchar", 128);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   139
        final String regex = System.getProperty("filter");
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   140
        final Pattern filter = (regex == null) ? null : Pattern.compile(regex);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   141
        final boolean useSecurityManager = Boolean.getBoolean("SecurityManager");
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   142
        if (useSecurityManager)
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   143
            System.setSecurityManager(new PermissiveSecurityManger());
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   144
        final Random rnd = new Random();
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   145
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   146
        for (Charset charset:  Charset.availableCharsets().values()) {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   147
            if (!("ISO-8859-1".equals(charset.name()) ||
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   148
                  "US-ASCII".equals(charset.name()) ||
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   149
                  charset.newDecoder() instanceof sun.nio.cs.SingleByte.Decoder))
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   150
                continue;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   151
            final String csn = charset.name();
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   152
            final Charset cs = charset;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   153
            final StringBuilder sb = new StringBuilder();
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   154
            {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   155
                final CharsetEncoder enc = cs.newEncoder();
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   156
                for (int i = 0; i < size; ) {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   157
                    char c = (char) rnd.nextInt(maxchar);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   158
                    if (enc.canEncode(c)) {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   159
                        sb.append(c);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   160
                        i++;
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   161
                    }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   162
                }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   163
            }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   164
            final String string = sb.toString();
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   165
            final byte[] bytes  = string.getBytes(cs);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   166
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   167
            System.out.printf("%n--------%s---------%n", csn);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   168
            for (int sz = 4; sz <= 2048; sz *= 2) {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   169
                System.out.printf("   [len=%d]%n", sz);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   170
                final byte[] bs  = Arrays.copyOf(bytes, sz);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   171
                final String str = new String(bs, csn);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   172
                Job[] jobs = {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   173
                    new Job("String decode: csn") {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   174
                    public void work() throws Throwable {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   175
                        for (int i = 0; i < itrs; i++)
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   176
                            new String(bs, csn);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   177
                    }},
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   178
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   179
                    new Job("String decode: cs") {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   180
                    public void work() throws Throwable {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   181
                        for (int i = 0; i < itrs; i++)
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   182
                            new String(bs, cs);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   183
                    }},
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   184
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   185
                    new Job("String encode: csn") {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   186
                    public void work() throws Throwable {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   187
                        for (int i = 0; i < itrs; i++)
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   188
                                str.getBytes(csn);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   189
                    }},
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   190
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   191
                    new Job("String encode: cs") {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   192
                    public void work() throws Throwable {
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   193
                         for (int i = 0; i < itrs; i++)
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   194
                          str.getBytes(cs);
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   195
                    }},
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   196
                };
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   197
                time(filter(filter, jobs));
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   198
            }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   199
        }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   200
    }
4259115772f7 6636323: Optimize handling of builtin charsets
sherman
parents:
diff changeset
   201
}