annotate graal/com.oracle.graal.debug.test/src/com/oracle/graal/debug/test/DebugHistogramTest.java @ 15954:cda2a7d1dcff

long values and scale on DebugHistogram
author Lukas Stadler <lukas.stadler@oracle.com>
date Wed, 28 May 2014 17:19:41 +0200
parents a771cc1f10f5
children 0ba1a6745070
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved.
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.debug.test;
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25 import java.io.*;
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27 import org.junit.*;
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29 import com.oracle.graal.debug.*;
11551
63b4694d3627 split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents: 9104
diff changeset
30 import com.oracle.graal.debug.internal.*;
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 public class DebugHistogramTest {
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 @Test
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 public void testEmptyHistogram() {
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 DebugHistogram histogram = Debug.createHistogram("TestHistogram");
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
11552
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
38
11551
63b4694d3627 split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents: 9104
diff changeset
39 new DebugHistogramAsciiPrinter(new PrintStream(outputStream)).print(histogram);
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40 Assert.assertEquals("TestHistogram is empty.\n", outputStream.toString());
11552
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
41
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
42 outputStream.reset();
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
43 new DebugHistogramRPrinter(new PrintStream(outputStream)).print(histogram);
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
44 Assert.assertEquals("", outputStream.toString());
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45 }
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47 @Test
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48 public void testSingleEntryHistogram() {
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
49 DebugHistogram histogram = Debug.createHistogram("TestHistogram");
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51 histogram.add(new Integer(1));
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 histogram.add(new Integer(1));
11551
63b4694d3627 split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents: 9104
diff changeset
53 new DebugHistogramAsciiPrinter(new PrintStream(outputStream)).print(histogram);
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
54 String[] lines = outputStream.toString().split("\n");
11552
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
55 // @formatter:off
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
56 String[] expected = {
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
57 "TestHistogram has 1 unique elements and 2 total elements:",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
58 "--------------------------------------------------------------------------------------------------------------------------------------------------------------------------",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
59 "| 1 | 2 | ==================================================================================================== |",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
60 "--------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
61 };
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
62 // @formatter:on
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
63 Assert.assertArrayEquals(expected, lines);
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
64
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
65 outputStream.reset();
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
66 new DebugHistogramRPrinter(new PrintStream(outputStream)).print(histogram);
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
67 lines = outputStream.toString().split("\n");
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
68 // @formatter:off
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
69 expected = new String[] {
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
70 "TestHistogram <- c(2);",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
71 "names(TestHistogram) <- c(\"1\");"
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
72 };
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
73 // @formatter:on
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
74 Assert.assertArrayEquals(expected, lines);
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 }
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77 @Test
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78 public void testMultipleEntryHistogram() {
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79 DebugHistogram histogram = Debug.createHistogram("TestHistogram");
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81 histogram.add(new Integer(1));
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 histogram.add(new Integer(2));
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83 histogram.add(new Integer(2));
11551
63b4694d3627 split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents: 9104
diff changeset
84 new DebugHistogramAsciiPrinter(new PrintStream(outputStream)).print(histogram);
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
85 String[] lines = outputStream.toString().split("\n");
11552
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
86 // @formatter:off
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
87 String[] expected = new String[] {
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
88 "TestHistogram has 2 unique elements and 3 total elements:",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
89 "--------------------------------------------------------------------------------------------------------------------------------------------------------------------------",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
90 "| 2 | 2 | ==================================================================================================== |",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
91 "| 1 | 1 | ================================================== |",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
92 "--------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
93 };
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
94 // @formatter:on
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
95 Assert.assertArrayEquals(expected, lines);
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
96
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
97 outputStream.reset();
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
98 new DebugHistogramRPrinter(new PrintStream(outputStream)).print(histogram);
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
99 lines = outputStream.toString().split("\n");
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
100 // @formatter:off
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
101 expected = new String[] {
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
102 "TestHistogram <- c(2, 1);",
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
103 "names(TestHistogram) <- c(\"2\", \"1\");"
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
104 };
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
105 // @formatter:on
a771cc1f10f5 added DebugHistogram printer that emits R statements to instantiate a vector of named values corresponding to the histogram
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
106 Assert.assertArrayEquals(expected, lines);
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
107 }
9104
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
108
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
109 @Test
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
110 public void testTooLongValueString() {
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
111 DebugHistogram histogram = Debug.createHistogram("TestHistogram");
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
112 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
113 histogram.add("MyCustomValue");
15954
cda2a7d1dcff long values and scale on DebugHistogram
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11552
diff changeset
114 new DebugHistogramAsciiPrinter(new PrintStream(outputStream), Integer.MAX_VALUE, 10, 10, 1).print(histogram);
9104
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
115 String[] lines = outputStream.toString().split("\n");
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
116 Assert.assertEquals(4, lines.length);
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
117 Assert.assertEquals("TestHistogram has 1 unique elements and 1 total elements:", lines[0]);
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
118 Assert.assertEquals("----------------------------------------", lines[1]);
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
119 Assert.assertEquals("| MyCusto... | 1 | ========== |", lines[2]);
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
120 Assert.assertEquals("----------------------------------------", lines[3]);
3495149b9531 Added support for trimming the name of objects in the histogram and a corresponding test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9103
diff changeset
121 }
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122 }