-
Notifications
You must be signed in to change notification settings - Fork 130
Add a chart to the web-site performance data #567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
670c711
91c7638
7063de7
31e279e
815a74c
dc515f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
|
|
||
| // Get the DOM container for the plot | ||
| var containerDOM = document.getElementById('appending_a_log_message_plot'); | ||
| if (!containerDOM) { | ||
| throw new Error("Could not find 'appending_a_log_message_plot' element"); | ||
| } | ||
| var myChart = echarts.init(containerDOM, null, { renderer: 'canvas' }); | ||
|
|
||
|
|
||
| // Find the benchmark html table | ||
| var benchmark_data = null; | ||
| var element = document.getElementById('benchmark_data_marker'); | ||
| while (element && element.tagName) { | ||
| if (element.tagName === 'TABLE') { | ||
| benchmark_data = element; | ||
| break; | ||
| } | ||
| element = element.nextElementSibling; | ||
| } | ||
| if (!benchmark_data) { | ||
| throw new Error("Could not find benchmark data");; | ||
| } | ||
|
|
||
| // Identify the benchmark tests to be included on the plot | ||
| var benchmark_pattern = []; | ||
| benchmark_pattern.push(new RegExp("Appending (.*) using ([A-Za-z]+), pattern: \\%m\\%n$")); | ||
| benchmark_pattern.push(new RegExp("Async, Sending (.*) using ([A-Za-z <]+)$")); | ||
| const value_regex_pattern = new RegExp("([0-9]+) ns") | ||
|
|
||
| // Extract the data | ||
| var plot_data = new Map(); | ||
| var xAxisLabels = []; | ||
| for (const row of benchmark_data.rows) { | ||
| const columns = row.cells; | ||
| if (2 < columns.length) { | ||
| const value_match = value_regex_pattern.exec(columns[1].innerText); | ||
| if (value_match && 1 < value_match.length) { | ||
| for (const pattern of benchmark_pattern) { | ||
| const benchmark_match = pattern.exec(columns[0].innerText); | ||
| if (benchmark_match && 2 < benchmark_match.length) { | ||
| if (!xAxisLabels.includes(benchmark_match[1])) { | ||
| xAxisLabels.push(benchmark_match[1]); | ||
| } | ||
| var keyValueMap = plot_data.get(benchmark_match[2]); | ||
| if (!keyValueMap) { | ||
| keyValueMap = new Map(); | ||
| plot_data.set(benchmark_match[2], keyValueMap); | ||
| } | ||
| keyValueMap.set(benchmark_match[1], value_match[1]); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Generate a series for each legend | ||
| var legend_data = []; | ||
| var series_data = []; | ||
| for (const [key, keyValueMap] of plot_data.entries()) { | ||
| legend_data.push(key); | ||
| var series_values = []; | ||
| for (const label of xAxisLabels) { | ||
| var value = keyValueMap.get(label); | ||
| series_values.push(value ? parseInt(value) : null); | ||
| } | ||
| var series_data_item = { | ||
| name: key, | ||
| type: 'line', | ||
| data: series_values | ||
| }; | ||
| series_data.push(series_data_item); | ||
| } | ||
|
|
||
| // Configure the chart | ||
| var chart_data = { | ||
| title: { text: 'Appending a log message' }, | ||
| yAxis: { | ||
| name: 'Average elapsed time (ns)', | ||
| nameLocation: 'center' | ||
| }, | ||
| legend: { | ||
| orient: 'vertical', | ||
| left: 150, | ||
| top: 'center', | ||
| data: legend_data | ||
| }, | ||
| xAxis: { | ||
| axisTick: { alignWithLabel: true }, | ||
| axisLabel: { rotate: 30 }, | ||
| name: 'Log message content', | ||
| nameLocation: 'center', | ||
| data: xAxisLabels | ||
| }, | ||
| series: series_data | ||
| }; | ||
|
|
||
| // Display the chart | ||
| myChart.setOption(chart_data); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test code kept intentionally?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found a test was necessary to quickly iterate through the vast landscape of echarts options. I am agnostic on whether it should be in the repository. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| </head> | ||
| <body> | ||
| <h1>Test page for iterating through echarts format options</h1> | ||
| <div id="appending_a_log_message_plot" style="width: 800px;height:400px;"></div> | ||
| <script src="echarts.min.js"></script> | ||
| <script src="test_echarts.js"></script> | ||
| </body> | ||
| <footer> | ||
|
|
||
| </footer> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| var chart_data = { | ||
| "title": { "text": "Appending a log message" }, | ||
| "legend": { | ||
| "orient": "vertical", | ||
| "left": 150, | ||
| "top": "center", | ||
| "data": [ "MessageBuffer", "FMT", "FMT and AsyncBuffer", "operator<< and AsyncBuffer" ] | ||
| }, | ||
| "xAxis": { | ||
| axisTick: { | ||
| alignWithLabel: true | ||
| }, | ||
| axisLabel: { | ||
| rotate: 30 | ||
| }, | ||
| name : 'Log message content', | ||
| nameLocation : 'center', | ||
| data : [ "5 char string", "49 char string", "int value", "int+float", "int+10float" ] | ||
| }, | ||
| "yAxis": { | ||
| name : 'Average elapsed time (ns)', | ||
| nameLocation : 'center' | ||
| }, | ||
| "series": [ | ||
| { "type": "line", "name": "MessageBuffer", "data": [ 334, 370, 509, 911, 4579 ] }, | ||
| { "type": "line", "name": "FMT", "data": [ null, 346, 376, 508, 1671 ] }, | ||
| { "type": "line", "name": "FMT and AsyncBuffer", "data": [ null, null, null, null, 784 ] }, | ||
| { "type": "line", "name": "operator<< and AsyncBuffer", "data": [ null, null, null, null, 1211 ] } | ||
| ] | ||
| }; | ||
|
|
||
| var containerDOM = document.getElementById('appending_a_log_message_plot'); | ||
| if (containerDOM) { | ||
| var myChart = echarts.init(containerDOM, null, { renderer: 'canvas' }); | ||
| myChart.setOption(chart_data); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some thoughts:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is simpler (zero maintenance) to use the data in the page to generate the graph.