more detailed stress testing metrics and graphs

This commit is contained in:
Lex Berezhny 2019-07-13 00:29:22 -04:00
parent 1eebe006ae
commit 84d3771984
2 changed files with 89 additions and 32 deletions

View file

@ -17,12 +17,12 @@ class Client {
channel = IOWebSocketChannel.connect(this.url); channel = IOWebSocketChannel.connect(this.url);
channel.stream.listen((message) { channel.stream.listen((message) {
Map data = json.decode(message); Map data = json.decode(message);
Map commands = data['commands'];
_metricsController.add( _metricsController.add(
MetricDataPoint() MetricDataPoint(
..search=data['search'] ?? 0 CommandMetrics.from_map(commands['search'] ?? {}),
..search_time=data['search_time'] ?? 0 CommandMetrics.from_map(commands['resolve'] ?? {})
..resolve=data['resolve'] ?? 0 )
..resolve_time=data['resolve_time'] ?? 0
); );
}); });
} }
@ -31,14 +31,45 @@ class Client {
} }
class CommandMetrics {
final int started;
final int finished;
final int total_time;
final int execution_time;
final int query_time;
final int query_count;
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;
CommandMetrics(
this.started, this.finished, this.total_time,
this.execution_time, this.query_time, this.query_count):
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,
avg_query_time_per_search=finished > 0 ? (query_time/finished).round() : 0,
avg_query_time_per_query=query_count > 0 ? (query_time/query_count).round() : 0;
CommandMetrics.from_map(Map data): this(
data['started'] ?? 0,
data['finished'] ?? 0,
data['total_time'] ?? 0,
data['execution_time'] ?? 0,
data['query_time'] ?? 0,
data['query_count'] ?? 0,
);
}
class MetricDataPoint { class MetricDataPoint {
final DateTime time = DateTime.now(); final DateTime time = DateTime.now();
int search = 0; final CommandMetrics search;
int search_time = 0; final CommandMetrics resolve;
int resolve = 0; MetricDataPoint(this.search, this.resolve);
int resolve_time = 0; MetricDataPoint.empty():
int get avg_search => search_time > 0 ? (search_time/search).round() : 0; search=CommandMetrics.from_map({}),
int get avg_resolve => resolve_time > 0 ? (resolve_time/resolve).round() : 0; resolve=CommandMetrics.from_map({});
} }

View file

@ -29,37 +29,64 @@ class _SimpleTimeSeriesChartState extends State<SimpleTimeSeriesChart> {
super.initState(); super.initState();
metricSeries.add( metricSeries.add(
charts.Series<MetricDataPoint, DateTime>( charts.Series<MetricDataPoint, DateTime>(
id: 'Searches', id: 'Searches Started',
colorFn: (_, __) => charts.MaterialPalette.black.darker, colorFn: (_, __) => charts.MaterialPalette.deepOrange.shadeDefault.lighter,
domainFn: (MetricDataPoint load, _) => load.time, domainFn: (MetricDataPoint load, _) => load.time,
measureFn: (MetricDataPoint load, _) => load.search, measureFn: (MetricDataPoint load, _) => load.search.started,
data: metricData, data: metricData,
) )
); );
metricSeries.add( metricSeries.add(
charts.Series<MetricDataPoint, DateTime>( charts.Series<MetricDataPoint, DateTime>(
id: 'Resolves', id: 'Searches Finished',
colorFn: (_, __) => charts.MaterialPalette.black.darker, colorFn: (_, __) => charts.MaterialPalette.deepOrange.shadeDefault.darker,
domainFn: (MetricDataPoint load, _) => load.time, domainFn: (MetricDataPoint load, _) => load.time,
measureFn: (MetricDataPoint load, _) => load.resolve, measureFn: (MetricDataPoint load, _) => load.search.finished,
data: metricData,
)
);
metricSeries.add(
charts.Series<MetricDataPoint, DateTime>(
id: 'Resolves Started',
colorFn: (_, __) => charts.MaterialPalette.teal.shadeDefault.lighter,
domainFn: (MetricDataPoint load, _) => load.time,
measureFn: (MetricDataPoint load, _) => load.resolve.started,
data: metricData,
)
);
metricSeries.add(
charts.Series<MetricDataPoint, DateTime>(
id: 'Resolves Finished',
colorFn: (_, __) => charts.MaterialPalette.teal.shadeDefault.darker,
domainFn: (MetricDataPoint load, _) => load.time,
measureFn: (MetricDataPoint load, _) => load.resolve.finished,
data: metricData, data: metricData,
) )
); );
metricTimeSeries.add( metricTimeSeries.add(
charts.Series<MetricDataPoint, DateTime>( charts.Series<MetricDataPoint, DateTime>(
id: 'Avg. Resolve Time', id: 'Avg. Waiting',
colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault.darker,
domainFn: (MetricDataPoint load, _) => load.time, domainFn: (MetricDataPoint load, _) => load.time,
measureFn: (MetricDataPoint load, _) => load.avg_resolve, measureFn: (MetricDataPoint load, _) => load.search.avg_wait_time,
data: metricData, data: metricData,
) )
); );
metricTimeSeries.add( metricTimeSeries.add(
charts.Series<MetricDataPoint, DateTime>( charts.Series<MetricDataPoint, DateTime>(
id: 'Avg. Search Time', id: 'Avg. Executing',
colorFn: (_, __) => charts.MaterialPalette.yellow.shadeDefault, colorFn: (_, __) => charts.MaterialPalette.teal.shadeDefault.lighter,
domainFn: (MetricDataPoint load, _) => load.time, domainFn: (MetricDataPoint load, _) => load.time,
measureFn: (MetricDataPoint load, _) => load.avg_search, measureFn: (MetricDataPoint load, _) => load.search.avg_execution_time,
data: metricData,
)
);
metricTimeSeries.add(
charts.Series<MetricDataPoint, DateTime>(
id: 'Avg. SQLite',
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault.darker,
domainFn: (MetricDataPoint load, _) => load.time,
measureFn: (MetricDataPoint load, _) => load.search.avg_query_time_per_search,
data: metricData, data: metricData,
) )
); );
@ -123,10 +150,11 @@ class _SimpleTimeSeriesChartState extends State<SimpleTimeSeriesChart> {
'id': 1, 'id': 1,
'method': 'blockchain.claimtrie.search', 'method': 'blockchain.claimtrie.search',
'params': { 'params': {
'no_totals': true,
'offset': 0, 'offset': 0,
'limit': 20, 'limit': 20,
'fee_amount': '<1', 'fee_amount': '<1',
'all_tags': ['funny'], //'all_tags': ['funny'],
'any_tags': [ 'any_tags': [
'crypto', 'crypto',
'outdoors', 'outdoors',
@ -139,19 +167,17 @@ class _SimpleTimeSeriesChartState extends State<SimpleTimeSeriesChart> {
//if (loadData.length > 60) loadData.removeAt(0); //if (loadData.length > 60) loadData.removeAt(0);
loadData.add(stats); loadData.add(stats);
}); });
increase = max(1, min(30, (increase*1.1).ceil())-stats.backlog); increase = max(1, min(100, increase+2)-stats.backlog);
//increase += 1; //increase += 1;
//t.query['params']['offset'] = (increase/2).ceil()*t.query['params']['limit']; //t.query['params']['offset'] = (increase/2).ceil()*t.query['params']['limit'];
t.load = increase;//rand.nextInt(10)+5; t.load = increase;//rand.nextInt(10)+5;
return true; return true;
})..start(); })..start();
metricData.add(MetricDataPoint()); metricData.add(MetricDataPoint.empty());
client = Client('ws://localhost:8181/')..open()..metrics.listen((m) { client = Client('ws://localhost:8181/')..open()..metrics.listen((m) {
setState(() { setState(() {
metricData.add(m); metricData.add(m);
}); });
print(m.avg_resolve);
print(m.avg_search);
}); });
} }
@ -165,10 +191,10 @@ class _SimpleTimeSeriesChartState extends State<SimpleTimeSeriesChart> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column(children: <Widget>[ return Column(children: <Widget>[
SizedBox(height: 250.0, child: BetterTimeSeriesChart(loadSeries)), SizedBox(height: 220.0, child: BetterTimeSeriesChart(loadSeries)),
SizedBox(height: 250.0, child: BetterTimeSeriesChart(timeSeries)), SizedBox(height: 220.0, child: BetterTimeSeriesChart(timeSeries)),
SizedBox(height: 250.0, child: BetterTimeSeriesChart(metricSeries)), SizedBox(height: 220.0, child: BetterTimeSeriesChart(metricSeries)),
SizedBox(height: 250.0, child: BetterTimeSeriesChart(metricTimeSeries)), SizedBox(height: 220.0, child: BetterTimeSeriesChart(metricTimeSeries)),
]); ]);
} }