ver gets cache hit info

This commit is contained in:
Lex Berezhny 2019-07-16 00:29:38 -04:00
parent e02a4e44c0
commit 6fb94e445f
3 changed files with 31 additions and 10 deletions

View file

@ -9,6 +9,7 @@ class LoadRequest {
final Map payload; final Map payload;
Completer completer; Completer completer;
Stopwatch timer; Stopwatch timer;
Socket socket;
bool get isDone => completer.isCompleted; bool get isDone => completer.isCompleted;
int get elapsed => timer.elapsedMilliseconds; int get elapsed => timer.elapsedMilliseconds;
@ -21,6 +22,7 @@ class LoadRequest {
completer.future.whenComplete(() => timer.stop()); completer.future.whenComplete(() => timer.stop());
try { try {
Socket.connect(this.host, this.port).then((socket) { Socket.connect(this.host, this.port).then((socket) {
this.socket = socket;
utf8.decoder.bind(socket).listen((r) { utf8.decoder.bind(socket).listen((r) {
if (r.contains('"jsonrpc": "2.0", "result": ')) { if (r.contains('"jsonrpc": "2.0", "result": ')) {
socket.close(); socket.close();
@ -54,6 +56,7 @@ class ClientLoadGenerator {
final LoadTickCallback tickCallback; final LoadTickCallback tickCallback;
int load = 1; int load = 1;
Map query; Map query;
List<LoadRequest> backlog = [];
ClientLoadGenerator(this.host, this.port, {this.tickCallback, this.query}) { ClientLoadGenerator(this.host, this.port, {this.tickCallback, this.query}) {
if (query == null) { if (query == null) {
@ -67,7 +70,7 @@ class ClientLoadGenerator {
start() { start() {
var previous = spawn_requests(); var previous = spawn_requests();
var backlog = <LoadRequest>[]; backlog = <LoadRequest>[];
_timer = Timer.periodic(Duration(seconds: 1), (t) { _timer = Timer.periodic(Duration(seconds: 1), (t) {
var stat = ClientLoadDataPoint(t.tick); var stat = ClientLoadDataPoint(t.tick);
backlog.removeWhere((r) { backlog.removeWhere((r) {
@ -94,6 +97,9 @@ class ClientLoadGenerator {
stop() { stop() {
_timer.cancel(); _timer.cancel();
for (var remaining in backlog) {
remaining?.socket?.close();
}
} }
List<LoadRequest> spawn_requests() { List<LoadRequest> spawn_requests() {

View file

@ -59,14 +59,15 @@ class APICallMetrics {
final int execution_time; final int execution_time;
final int query_time; final int query_time;
final int query_count; final int query_count;
final int cache_hit;
final int avg_wait_time; final int avg_wait_time;
final int avg_total_time; final int avg_total_time;
final int avg_execution_time; final int avg_execution_time;
final int avg_query_time_per_search; final int avg_query_time_per_search;
final int avg_query_time_per_query; final int avg_query_time_per_query;
APICallMetrics( APICallMetrics(
this.started, this.finished, this.total_time, this.started, this.finished, this.total_time, this.execution_time,
this.execution_time, this.query_time, this.query_count): this.query_time, this.query_count, this.cache_hit):
avg_wait_time=finished > 0 ? ((total_time - (execution_time + query_time))/finished).round() : 0, avg_wait_time=finished > 0 ? ((total_time - (execution_time + query_time))/finished).round() : 0,
avg_total_time=finished > 0 ? (total_time/finished).round() : 0, avg_total_time=finished > 0 ? (total_time/finished).round() : 0,
avg_execution_time=finished > 0 ? (execution_time/finished).round() : 0, avg_execution_time=finished > 0 ? (execution_time/finished).round() : 0,
@ -79,6 +80,7 @@ class APICallMetrics {
data['execution_time'] ?? 0, data['execution_time'] ?? 0,
data['query_time'] ?? 0, data['query_time'] ?? 0,
data['query_count'] ?? 0, data['query_count'] ?? 0,
data['cache_hit'] ?? 0,
); );
} }

View file

@ -40,7 +40,7 @@ class ServerLoadChartState extends State<ServerLoadChart> {
super.initState(); super.initState();
seriesData = [ seriesData = [
charts.Series<ServerLoadDataPoint, int>( charts.Series<ServerLoadDataPoint, int>(
id: 'Searches Started', id: 'Search Start',
colorFn: (_, __) => colorFn: (_, __) =>
charts.MaterialPalette.deepOrange.shadeDefault.lighter, charts.MaterialPalette.deepOrange.shadeDefault.lighter,
domainFn: (ServerLoadDataPoint load, _) => load.tick, domainFn: (ServerLoadDataPoint load, _) => load.tick,
@ -48,7 +48,7 @@ class ServerLoadChartState extends State<ServerLoadChart> {
data: widget.server.serverLoadData, data: widget.server.serverLoadData,
), ),
charts.Series<ServerLoadDataPoint, int>( charts.Series<ServerLoadDataPoint, int>(
id: 'Searches Finished', id: 'Search Finish',
colorFn: (_, __) => colorFn: (_, __) =>
charts.MaterialPalette.deepOrange.shadeDefault.darker, charts.MaterialPalette.deepOrange.shadeDefault.darker,
domainFn: (ServerLoadDataPoint load, _) => load.tick, domainFn: (ServerLoadDataPoint load, _) => load.tick,
@ -56,20 +56,33 @@ class ServerLoadChartState extends State<ServerLoadChart> {
data: widget.server.serverLoadData, data: widget.server.serverLoadData,
), ),
charts.Series<ServerLoadDataPoint, int>( charts.Series<ServerLoadDataPoint, int>(
id: 'Resolves Started', id: 'Search Cache',
colorFn: (_, __) => colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault.darker,
charts.MaterialPalette.teal.shadeDefault.lighter, domainFn: (ServerLoadDataPoint load, _) => load.tick,
measureFn: (ServerLoadDataPoint load, _) => load.search.cache_hit,
data: widget.server.serverLoadData,
),
charts.Series<ServerLoadDataPoint, int>(
id: 'Resolve Start',
colorFn: (_, __) => charts.MaterialPalette.teal.shadeDefault.lighter,
domainFn: (ServerLoadDataPoint load, _) => load.tick, domainFn: (ServerLoadDataPoint load, _) => load.tick,
measureFn: (ServerLoadDataPoint load, _) => load.resolve.started, measureFn: (ServerLoadDataPoint load, _) => load.resolve.started,
data: widget.server.serverLoadData, data: widget.server.serverLoadData,
), ),
charts.Series<ServerLoadDataPoint, int>( charts.Series<ServerLoadDataPoint, int>(
id: 'Resolves Finished', id: 'Resolve Finish',
colorFn: (_, __) => charts.MaterialPalette.teal.shadeDefault.darker, colorFn: (_, __) => charts.MaterialPalette.teal.shadeDefault.darker,
domainFn: (ServerLoadDataPoint load, _) => load.tick, domainFn: (ServerLoadDataPoint load, _) => load.tick,
measureFn: (ServerLoadDataPoint load, _) => load.resolve.finished, measureFn: (ServerLoadDataPoint load, _) => load.resolve.finished,
data: widget.server.serverLoadData, data: widget.server.serverLoadData,
) ),
charts.Series<ServerLoadDataPoint, int>(
id: 'Resolve Cache',
colorFn: (_, __) => charts.MaterialPalette.cyan.shadeDefault.darker,
domainFn: (ServerLoadDataPoint load, _) => load.tick,
measureFn: (ServerLoadDataPoint load, _) => load.resolve.cache_hit,
data: widget.server.serverLoadData,
),
]; ];
} }