annotate test/runtime/7158800/InternTest.java @ 6810:a3fd4914ac81

Added tag jdk8-b59 for changeset 8a1a6b9b4f20
author katleman
date Thu, 04 Oct 2012 14:34:51 -0700
parents e9140bf80b4a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6162
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
1 /*
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
4 *
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
7 * published by the Free Software Foundation.
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
8 *
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
13 * accompanied this code).
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
14 *
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
18 *
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
21 * questions.
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
22 */
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
23
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
24 /*
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
25 * @test
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
26 * @bug 7158800
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
27 * @run shell/timeout=400 Test7158800.sh
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
28 * @summary This test performs poorly if alternate hashing isn't used for
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
29 * string table.
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
30 * The timeout is handled by the shell file (which kills the process)
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
31 */
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
32 import java.util.*;
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
33 import java.io.*;
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
34
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
35 public class InternTest {
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
36 public static void main (String args[]) throws Exception {
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
37 final String badStringsFilename = "badstrings.txt";
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
38
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
39 if (args.length == 0 || (!args[0].equals("bad") && !args[0].equals("normal"))) {
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
40 System.out.println("Usage: java InternTest [normal|bad]");
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
41 System.exit(1);
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
42 }
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
43
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
44 FileInputStream fstream = new FileInputStream(badStringsFilename);
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
45 DataInputStream in = new DataInputStream(fstream);
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
46 BufferedReader br = new BufferedReader(new InputStreamReader(in));
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
47 String toIntern, toDiscard;
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
48 int count = 0;
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
49 long current = 0L;
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
50 long last = System.currentTimeMillis();
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
51
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
52 if (args[0].equals("bad")) {
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
53 while ((toIntern = br.readLine()) != null) {
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
54 toDiscard = new String((new Integer((int)(Math.random() * Integer.MAX_VALUE))).toString());
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
55 toIntern.intern();
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
56 count++;
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
57 if (count % 10000 == 0 && count != 0) {
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
58 current = System.currentTimeMillis();
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
59 System.out.println(new Date(current) + ": interned " + count + " 0-hash strings - last 10000 took " + ((float)(current - last))/1000 + "s (" + ((float)(current - last))/10000000 + "s per String)");
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
60 last = current;
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
61 }
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
62 }
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
63 }
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
64 if (args[0].equals("normal")) {
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
65 while ((toDiscard = br.readLine()) != null) { // do the same read from the file to try and make the test fair
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
66 toIntern = new String((new Integer((int)(Math.random() * Integer.MAX_VALUE))).toString());
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
67 toIntern.intern();
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
68 count++;
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
69 if (count % 10000 == 0 && count != 0) {
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
70 current = System.currentTimeMillis();
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
71 System.out.println(new Date(current) + ": interned " + count + " normal strings - last 10000 took " + ((float)(current - last))/1000 + "s (" + ((float)(current - last))/10000000 + "s per String)");
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
72 last = current;
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
73 }
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
74 }
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
75 }
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
76 in.close();
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
77 }
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
78 }
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
79
e9140bf80b4a 7158800: Improve storage of symbol tables
coleenp
parents:
diff changeset
80