1 /*
2 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
318 * Tests
319 */
320
321 private static final int LargeNumberOfStrings = 10000;
322 private static final int SmallNumberOfStrings = 10;
323
324 private static final int MaxAgeThreshold = 15;
325 private static final int DefaultAgeThreshold = 3;
326 private static final int MinAgeThreshold = 1;
327
328 private static final int TooLowAgeThreshold = MinAgeThreshold - 1;
329 private static final int TooHighAgeThreshold = MaxAgeThreshold + 1;
330
331 public static void testYoungGC() throws Exception {
332 // Do young GC to age strings to provoke deduplication
333 OutputAnalyzer output = DeduplicationTest.run(LargeNumberOfStrings,
334 DefaultAgeThreshold,
335 YoungGC,
336 "-Xlog:gc,gc+stringdedup=trace");
337 output.shouldNotContain("Full GC");
338 output.shouldContain("Pause Young (G1 Evacuation Pause)");
339 output.shouldContain("Concurrent String Deduplication");
340 output.shouldContain("Deduplicated:");
341 output.shouldHaveExitValue(0);
342 }
343
344 public static void testFullGC() throws Exception {
345 // Do full GC to age strings to provoke deduplication
346 OutputAnalyzer output = DeduplicationTest.run(LargeNumberOfStrings,
347 DefaultAgeThreshold,
348 FullGC,
349 "-Xlog:gc,gc+stringdedup=trace");
350 output.shouldNotContain("Pause Young (G1 Evacuation Pause)");
351 output.shouldContain("Full GC");
352 output.shouldContain("Concurrent String Deduplication");
353 output.shouldContain("Deduplicated:");
354 output.shouldHaveExitValue(0);
355 }
356
357 public static void testTableResize() throws Exception {
358 // Test with StringDeduplicationResizeALot
359 OutputAnalyzer output = DeduplicationTest.run(LargeNumberOfStrings,
360 DefaultAgeThreshold,
361 YoungGC,
362 "-Xlog:gc,gc+stringdedup=trace",
363 "-XX:+StringDeduplicationResizeALot");
364 output.shouldContain("Concurrent String Deduplication");
365 output.shouldContain("Deduplicated:");
366 output.shouldNotContain("Resize Count: 0");
367 output.shouldHaveExitValue(0);
368 }
369
370 public static void testTableRehash() throws Exception {
|
1 /*
2 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
318 * Tests
319 */
320
321 private static final int LargeNumberOfStrings = 10000;
322 private static final int SmallNumberOfStrings = 10;
323
324 private static final int MaxAgeThreshold = 15;
325 private static final int DefaultAgeThreshold = 3;
326 private static final int MinAgeThreshold = 1;
327
328 private static final int TooLowAgeThreshold = MinAgeThreshold - 1;
329 private static final int TooHighAgeThreshold = MaxAgeThreshold + 1;
330
331 public static void testYoungGC() throws Exception {
332 // Do young GC to age strings to provoke deduplication
333 OutputAnalyzer output = DeduplicationTest.run(LargeNumberOfStrings,
334 DefaultAgeThreshold,
335 YoungGC,
336 "-Xlog:gc,gc+stringdedup=trace");
337 output.shouldNotContain("Full GC");
338 output.shouldContain("Pause Young (Normal) (G1 Evacuation Pause)");
339 output.shouldContain("Concurrent String Deduplication");
340 output.shouldContain("Deduplicated:");
341 output.shouldHaveExitValue(0);
342 }
343
344 public static void testFullGC() throws Exception {
345 // Do full GC to age strings to provoke deduplication
346 OutputAnalyzer output = DeduplicationTest.run(LargeNumberOfStrings,
347 DefaultAgeThreshold,
348 FullGC,
349 "-Xlog:gc,gc+stringdedup=trace");
350 output.shouldNotContain("Pause Young (Normal) (G1 Evacuation Pause)");
351 output.shouldContain("Full GC");
352 output.shouldContain("Concurrent String Deduplication");
353 output.shouldContain("Deduplicated:");
354 output.shouldHaveExitValue(0);
355 }
356
357 public static void testTableResize() throws Exception {
358 // Test with StringDeduplicationResizeALot
359 OutputAnalyzer output = DeduplicationTest.run(LargeNumberOfStrings,
360 DefaultAgeThreshold,
361 YoungGC,
362 "-Xlog:gc,gc+stringdedup=trace",
363 "-XX:+StringDeduplicationResizeALot");
364 output.shouldContain("Concurrent String Deduplication");
365 output.shouldContain("Deduplicated:");
366 output.shouldNotContain("Resize Count: 0");
367 output.shouldHaveExitValue(0);
368 }
369
370 public static void testTableRehash() throws Exception {
|