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

View file

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

View file

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