From 779d96e017c78061df5d1d0fe3bf234b5f72e730 Mon Sep 17 00:00:00 2001 From: Ganesh Patil Date: Mon, 20 Jun 2016 21:14:41 +0530 Subject: [PATCH] In the Top Running Methods list, list thread names per top method and link them all to the stack traces list. fixed the test failures Added tests for top_methods_from_running_threads --- analyze.js | 25 ++++++++++++------------- stylesheet.css | 5 +++++ tests.js | 26 ++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/analyze.js b/analyze.js index 29c0ca3..2eda8f3 100644 --- a/analyze.js +++ b/analyze.js @@ -797,27 +797,26 @@ function Analyzer(text) { return this.countedRunningMethods.toString(); }; + this.getSourceInfo = function(source){ + return [ + '', + htmlEscape(source.name), + '' + ].join(''); + }; + this.toRunningHtml = function() { var html = ""; var countedStrings = this.countedRunningMethods.getStrings(); for (var i = 0; i < countedStrings.length; i++) { var countedString = countedStrings[i]; - + var ids = countedString.sources.map(this.getSourceInfo); html += ''; - html += countedString.count; - html += ''; - - // Link to the thread currently executing this method - if (countedString.count === 1) { - html += ''; - } + html += '">'; html += htmlEscape(countedString.string); - if (countedString.count === 1) { - html += ''; - } - + html += ''; + html += ids.join('
'); html += "\n"; } return html; diff --git a/stylesheet.css b/stylesheet.css index 481b3ae..04774d5 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -55,6 +55,11 @@ div.synchronizer { margin-top: 0.25em; } +.vertical-align{ + vertical-align: top; + padding-top: 10px; +} + :target { color: inherit; background-color: #ffa; diff --git a/tests.js b/tests.js index 4b7ab09..a567f53 100644 --- a/tests.js +++ b/tests.js @@ -487,6 +487,32 @@ QUnit.test( "full dump analysis", function(assert) { assert.deepEqual(analyzer.toRunningString().split('\n'), expectedRunning.split('\n')); }); +QUnit.test( "Top Methods from running threads", function(assert) { + var input = unescapeHtml(document.getElementById("sample-input").innerHTML); + var analyzer = new Analyzer(input); + var running = analyzer.toRunningHtml(); + var expectedRunning = [ + '', + 'java.net.PlainSocketImpl.socketAccept(Native Method)', + '', + 'RMI TCP Accept-0
', + 'Lock thread', + '', + '\n', + '', + 'java.lang.UNIXProcess.waitForProcessExit(Native Method)', + '', + 'process reaper', + '', + '\n', + '', + 'sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)', + 'ApplicationImpl pooled thread 9', + '\n' + ].join(''); + assert.equal(running, expectedRunning); +}); + QUnit.test("extract regex from string", function(assert) { var extracted = _extract(/a(p)a/, "gris"); assert.equal(extracted.value, undefined);