-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanalyzer.html
109 lines (107 loc) · 4.71 KB
/
analyzer.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Thread Dump Analyzer</title>
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css">
<link href="analyzer.css" media="all" rel="stylesheet" type="text/css" />
<body>
<div class="jumbotron" id="jumbotron">
<h1>Thread Dump Analyzer</h1>
<p>Drop your JVM THREAD DUMP FILE on text area, or paste , or select this <input type="file" id="load-dump" value="load dump" /></p>
<a href="#" id="scroll-top" style="float:right" title="scroll to top">^^^</a>
<textarea id="dump" wrap="off">
</textarea><br />
</div>
<center style="margin:48px"><button id="parse-action" class="btn btn-lg btn-primary disabled">analyze! <span id="fname"></span></button></center>
<div id="parse-result">
</div>
<script src="https://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="analyzer.js"></script>
<script>
$(function(){
function loadFile(files){
if(files && files[0]){
var fileReader = new FileReader();
fileReader.onload = function(e){
$("#dump").val(e.target.result).trigger("change");
$("#fname").text(files[0].name);
};
fileReader.onerror = function(){ alert("can't read!"); }
fileReader.readAsText(files[0]);
}
}
$("#parse-result").delegate('.lineNum','click',function(){
$("#dump").scrollTop(parseInt($(this).text()) * parseInt($("#dump").css('line-height')));
});
$("#parse-action").click(function(){
$("#parse-action").addClass("disabled");
var parseState = $('<div class="progress" id="progress"><div class="progress-bar progress-striped">').insertBefore("#parse-result");
$('html, body').animate({scrollTop: $("#parse-action").offset().top}, 1500 );
parse($("#dump").val().split(/\r\n|\r|\n/),$("#parse-result").html(parseState),function(line,lineMax, threadDumps){
if(line==lineMax){
$(".threads:first").find("label.lb-RUNNABLE, label.lb-BLOCKED").button('toggle');
var nlast = 0;
parseState.html("");
function pbar(klass,size){
return $('<div class="progress-bar progress-bar-'+klass+'" style="width: '+(size/10)+'%">').appendTo(parseState);
}
$.each(threadDumps,function(){
var n = Math.floor(1000*this.startLineNumber/lineMax);
if(n!=nlast){
pbar("warning",n-nlast).text("not thread dump");
}
nlast = Math.floor(1000*this.endLineNumber/lineMax);
pbar("success",nlast-n).text(this.timeText);
});
if(nlast!=1000){
pbar("warning",1000-nlast).text(this.timeText);
}
}else{
parseState.find(".progress-bar").css("width",Math.floor((line*100)/lineMax)+"%").text(line+"/"+lineMax+" "+Math.floor((line*100)/lineMax)+"%");
}
});
});
$("#jumbotron").on("drop",function(e){
if(e.originalEvent && e.originalEvent.dataTransfer && e.originalEvent.dataTransfer){
loadFile(e.originalEvent.dataTransfer.files);
}
return false;
});
$("#dump").change(function(){
if(this.value.length!=0){
$("#parse-action").removeClass("disabled");
}
}).keyup(function(){
$(this).trigger("change");
});
$("#load-dump").on("change",function(e){
if(e.target){
loadFile(e.target.files);
}
return false;
});
$("#scroll-top").click(function(){
$("#dump").scrollTop(0);
});
(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs'));
});
</script>
<footer>
<ul class="bs-social-buttons">
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=nazoking&repo=thread-dump-analyzer&type=watch&count=true" width="100" height="20" title="Star on GitHub"></iframe>
</li>
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=nazoking&repo=thread-dump-analyzer&type=fork&count=true" width="102" height="20" title="Fork on GitHub"></iframe>
</li>
<li class="follow-btn">
<a href="https://twitter.com/nazoking" class="twitter-follow-button" data-show-count="false" data-lang="ja">follow @nazoking</a>
</li>
<li class="tweet-btn">
<a href="https://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="nazoking" data-url="http://nazoking.github.io/thread-dump-analyzer/analyzer.html" >Tweet</a>
</li>
</ul>
</footer>
</body>
</html>