forked from LBRYCommunity/lbry-sdk
more detailed stress testing metrics and graphs
This commit is contained in:
parent
1eebe006ae
commit
84d3771984
2 changed files with 89 additions and 32 deletions
|
@ -17,12 +17,12 @@ class Client {
|
|||
channel = IOWebSocketChannel.connect(this.url);
|
||||
channel.stream.listen((message) {
|
||||
Map data = json.decode(message);
|
||||
Map commands = data['commands'];
|
||||
_metricsController.add(
|
||||
MetricDataPoint()
|
||||
..search=data['search'] ?? 0
|
||||
..search_time=data['search_time'] ?? 0
|
||||
..resolve=data['resolve'] ?? 0
|
||||
..resolve_time=data['resolve_time'] ?? 0
|
||||
MetricDataPoint(
|
||||
CommandMetrics.from_map(commands['search'] ?? {}),
|
||||
CommandMetrics.from_map(commands['resolve'] ?? {})
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -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 {
|
||||
final DateTime time = DateTime.now();
|
||||
int search = 0;
|
||||
int search_time = 0;
|
||||
int resolve = 0;
|
||||
int resolve_time = 0;
|
||||
int get avg_search => search_time > 0 ? (search_time/search).round() : 0;
|
||||
int get avg_resolve => resolve_time > 0 ? (resolve_time/resolve).round() : 0;
|
||||
final CommandMetrics search;
|
||||
final CommandMetrics resolve;
|
||||
MetricDataPoint(this.search, this.resolve);
|
||||
MetricDataPoint.empty():
|
||||
search=CommandMetrics.from_map({}),
|
||||
resolve=CommandMetrics.from_map({});
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -29,37 +29,64 @@ class _SimpleTimeSeriesChartState extends State<SimpleTimeSeriesChart> {
|
|||
super.initState();
|
||||
metricSeries.add(
|
||||
charts.Series<MetricDataPoint, DateTime>(
|
||||
id: 'Searches',
|
||||
colorFn: (_, __) => charts.MaterialPalette.black.darker,
|
||||
id: 'Searches Started',
|
||||
colorFn: (_, __) => charts.MaterialPalette.deepOrange.shadeDefault.lighter,
|
||||
domainFn: (MetricDataPoint load, _) => load.time,
|
||||
measureFn: (MetricDataPoint load, _) => load.search,
|
||||
measureFn: (MetricDataPoint load, _) => load.search.started,
|
||||
data: metricData,
|
||||
)
|
||||
);
|
||||
metricSeries.add(
|
||||
charts.Series<MetricDataPoint, DateTime>(
|
||||
id: 'Resolves',
|
||||
colorFn: (_, __) => charts.MaterialPalette.black.darker,
|
||||
id: 'Searches Finished',
|
||||
colorFn: (_, __) => charts.MaterialPalette.deepOrange.shadeDefault.darker,
|
||||
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,
|
||||
)
|
||||
);
|
||||
metricTimeSeries.add(
|
||||
charts.Series<MetricDataPoint, DateTime>(
|
||||
id: 'Avg. Resolve Time',
|
||||
colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault,
|
||||
id: 'Avg. Waiting',
|
||||
colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault.darker,
|
||||
domainFn: (MetricDataPoint load, _) => load.time,
|
||||
measureFn: (MetricDataPoint load, _) => load.avg_resolve,
|
||||
measureFn: (MetricDataPoint load, _) => load.search.avg_wait_time,
|
||||
data: metricData,
|
||||
)
|
||||
);
|
||||
metricTimeSeries.add(
|
||||
charts.Series<MetricDataPoint, DateTime>(
|
||||
id: 'Avg. Search Time',
|
||||
colorFn: (_, __) => charts.MaterialPalette.yellow.shadeDefault,
|
||||
id: 'Avg. Executing',
|
||||
colorFn: (_, __) => charts.MaterialPalette.teal.shadeDefault.lighter,
|
||||
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,
|
||||
)
|
||||
);
|
||||
|
@ -123,10 +150,11 @@ class _SimpleTimeSeriesChartState extends State<SimpleTimeSeriesChart> {
|
|||
'id': 1,
|
||||
'method': 'blockchain.claimtrie.search',
|
||||
'params': {
|
||||
'no_totals': true,
|
||||
'offset': 0,
|
||||
'limit': 20,
|
||||
'fee_amount': '<1',
|
||||
'all_tags': ['funny'],
|
||||
//'all_tags': ['funny'],
|
||||
'any_tags': [
|
||||
'crypto',
|
||||
'outdoors',
|
||||
|
@ -139,19 +167,17 @@ class _SimpleTimeSeriesChartState extends State<SimpleTimeSeriesChart> {
|
|||
//if (loadData.length > 60) loadData.removeAt(0);
|
||||
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;
|
||||
//t.query['params']['offset'] = (increase/2).ceil()*t.query['params']['limit'];
|
||||
t.load = increase;//rand.nextInt(10)+5;
|
||||
return true;
|
||||
})..start();
|
||||
metricData.add(MetricDataPoint());
|
||||
metricData.add(MetricDataPoint.empty());
|
||||
client = Client('ws://localhost:8181/')..open()..metrics.listen((m) {
|
||||
setState(() {
|
||||
metricData.add(m);
|
||||
});
|
||||
print(m.avg_resolve);
|
||||
print(m.avg_search);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -165,10 +191,10 @@ class _SimpleTimeSeriesChartState extends State<SimpleTimeSeriesChart> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(children: <Widget>[
|
||||
SizedBox(height: 250.0, child: BetterTimeSeriesChart(loadSeries)),
|
||||
SizedBox(height: 250.0, child: BetterTimeSeriesChart(timeSeries)),
|
||||
SizedBox(height: 250.0, child: BetterTimeSeriesChart(metricSeries)),
|
||||
SizedBox(height: 250.0, child: BetterTimeSeriesChart(metricTimeSeries)),
|
||||
SizedBox(height: 220.0, child: BetterTimeSeriesChart(loadSeries)),
|
||||
SizedBox(height: 220.0, child: BetterTimeSeriesChart(timeSeries)),
|
||||
SizedBox(height: 220.0, child: BetterTimeSeriesChart(metricSeries)),
|
||||
SizedBox(height: 220.0, child: BetterTimeSeriesChart(metricTimeSeries)),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue