refresh & clear

This commit is contained in:
Sander Hautvast 2018-07-18 15:26:13 +02:00
parent ea1f4ae163
commit bd1ee0cfe9
3 changed files with 28 additions and 6 deletions

View file

@ -88,4 +88,8 @@ public class Registry {
});
}
public static void clear() {
methods.clear();
callstack.clear();
}
}

View file

@ -5,7 +5,6 @@ import perfix.Registry;
import perfix.server.json.Serializer;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
public class HTTPServer extends NanoHTTPD {
@ -33,7 +32,10 @@ public class HTTPServer extends NanoHTTPD {
return perfixMetrics();
case "/callstack":
return perfixCallstack();
default: return newFixedLengthResponse(Response.Status.NOT_FOUND, "text/plain", "NOT FOUND");
case "/clear":
return clear();
default:
return newFixedLengthResponse(Response.Status.NOT_FOUND, "text/plain", "NOT FOUND");
}
}
@ -61,4 +63,14 @@ public class HTTPServer extends NanoHTTPD {
}
}
private Response clear() {
Registry.clear();
try {
return addCors(newFixedLengthResponse(Response.Status.OK, "application/json", Serializer.toJSONString(Registry.getCallStack())));
} catch (Exception e) {
e.printStackTrace();
return newFixedLengthResponse(e.toString());
}
}
}

View file

@ -14,11 +14,16 @@ class Tree extends Component {
.then(response => this.setState({ data: response.data }));
}
clear() {
axios.get("http://localhost:2048/clear")
.then(response => this.setState({ data: response.data }));
}
renderChildren(children) {
return (<ul className="tree">
{children.map(
r =>
<li><input type="checkbox" className="tree"></input>
<li key={r.report.name}><input type="checkbox" className="tree"></input>
{Math.floor(r.report.average / 1000) / 1000} ms &nbsp;
- {r.report.invocations} inv. &nbsp;
{r.report.name}
@ -31,9 +36,10 @@ class Tree extends Component {
render() {
return (
<div>
<button type="button" onClick={this.clear}>clear</button>
<button type="button" onClick={this.loadData}>refresh</button>
<div className="view"><h1>Callstack view</h1>
<div className="treeView">
{/* <button type="button" onClick={this.loadData()}> refresh </button> */}
{this.renderChildren(this.state.data)}
</div>
</div>