diff options
author | 2017-02-21 10:54:51 +0000 | |
---|---|---|
committer | 2017-02-21 10:54:52 +0000 | |
commit | 89bed6d6fcd687cfedd10c14927c104eddf99c7f (patch) | |
tree | c044cdb91c15a4827cb1a15a6b35cd6b7ef9e37b /tools/ahat/src/DocString.java | |
parent | 8ca86eae1f6030782b2646b5b5b0976e06227233 (diff) | |
parent | d640e29f9dad93f51e74026327dd53bb5a30eb33 (diff) |
Merge changes Ic39b6d55,Id9a392ac,I1a6b05ea
* changes:
Show unreachable objects in ahat.
ahat: add support for diffing two heap dumps.
Refactor ahat's perflib api.
Diffstat (limited to 'tools/ahat/src/DocString.java')
-rw-r--r-- | tools/ahat/src/DocString.java | 73 |
1 files changed, 72 insertions, 1 deletions
diff --git a/tools/ahat/src/DocString.java b/tools/ahat/src/DocString.java index 19666dea8c..c6303c8c35 100644 --- a/tools/ahat/src/DocString.java +++ b/tools/ahat/src/DocString.java @@ -53,7 +53,6 @@ class DocString { public static DocString link(URI uri, DocString content) { DocString doc = new DocString(); return doc.appendLink(uri, content); - } /** @@ -86,6 +85,78 @@ class DocString { return this; } + /** + * Adorn the given string to indicate it represents something added relative + * to a baseline. + */ + public static DocString added(DocString str) { + DocString string = new DocString(); + string.mStringBuilder.append("<span class=\"added\">"); + string.mStringBuilder.append(str.html()); + string.mStringBuilder.append("</span>"); + return string; + } + + /** + * Adorn the given string to indicate it represents something added relative + * to a baseline. + */ + public static DocString added(String str) { + return added(text(str)); + } + + /** + * Adorn the given string to indicate it represents something removed relative + * to a baseline. + */ + public static DocString removed(DocString str) { + DocString string = new DocString(); + string.mStringBuilder.append("<span class=\"removed\">"); + string.mStringBuilder.append(str.html()); + string.mStringBuilder.append("</span>"); + return string; + } + + /** + * Adorn the given string to indicate it represents something removed relative + * to a baseline. + */ + public static DocString removed(String str) { + return removed(text(str)); + } + + /** + * Standard formatted DocString for describing a change in size relative to + * a baseline. + * @param noCurrent - whether no current object exists. + * @param noBaseline - whether no basline object exists. + * @param current - the size of the current object. + * @param baseline - the size of the baseline object. + */ + public static DocString delta(boolean noCurrent, boolean noBaseline, + long current, long baseline) { + DocString doc = new DocString(); + return doc.appendDelta(noCurrent, noBaseline, current, baseline); + } + + /** + * Standard formatted DocString for describing a change in size relative to + * a baseline. + */ + public DocString appendDelta(boolean noCurrent, boolean noBaseline, + long current, long baseline) { + if (noCurrent) { + append(removed(format("%+,14d", 0 - baseline))); + } else if (noBaseline) { + append(added("new")); + } else if (current > baseline) { + append(added(format("%+,14d", current - baseline))); + } else if (current < baseline) { + append(removed(format("%+,14d", current - baseline))); + } + return this; + } + public DocString appendLink(URI uri, DocString content) { mStringBuilder.append("<a href=\""); mStringBuilder.append(uri.toASCIIString()); |