[llvm-commits] [zorg] r132156 - in /zorg/trunk/lnt/lnt/server/ui: static/order_aggregate_ui.js templates/simple_order_aggregate_report.html
Daniel Dunbar
daniel at zuster.org
Thu May 26 15:00:53 PDT 2011
Author: ddunbar
Date: Thu May 26 17:00:53 2011
New Revision: 132156
URL: http://llvm.org/viewvc/llvm-project?rev=132156&view=rev
Log:
LNT/Order UI: Start sketching JS UI code.
Added:
zorg/trunk/lnt/lnt/server/ui/static/order_aggregate_ui.js
Modified:
zorg/trunk/lnt/lnt/server/ui/templates/simple_order_aggregate_report.html
Added: zorg/trunk/lnt/lnt/server/ui/static/order_aggregate_ui.js
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/static/order_aggregate_ui.js?rev=132156&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/server/ui/static/order_aggregate_ui.js (added)
+++ zorg/trunk/lnt/lnt/server/ui/static/order_aggregate_ui.js Thu May 26 17:00:53 2011
@@ -0,0 +1,128 @@
+/*** Order Aggregate Report UI ***/
+
+function sum(list) {
+ var result = 0.0;
+ for (var i = 0; i != list.length; ++i)
+ result += list[i];
+ return result;
+}
+
+function mean(list) {
+ if (list.length === 0)
+ return 0.0;
+
+ return sum(list) / list.length;
+}
+
+/* AggregateGraphWidget Class */
+function AggregateGraphWidget(oar, name) {
+ this.oar = oar;
+ this.name = name;
+ this.widget = null;
+ this.graph_data = null;
+ this.plots = null;
+}
+
+AggregateGraphWidget.prototype.init = function(parent) {
+ this.widget = $('<div class="oar_graph_widget"></div>');
+ this.widget.prependTo(parent);
+
+ // Create the graph element.
+ this.graph_elt = $('<div id="' + this.name + '.plot" ' +
+ 'style="width:400px;height:300px;"></div>');
+ this.graph_elt.appendTo(this.widget);
+}
+
+AggregateGraphWidget.prototype.compute_aggregate_for_run =
+ function(subset_name, order_idx, machine_idx)
+{
+ var test_names = this.oar.data.test_subsets[subset_name];
+ var test_data = this.oar.data.data_table[subset_name];
+ var pts = []
+
+ for (var i = 0; i != test_names.length; ++i) {
+ var baseline = test_data[test_names[i]][0][machine_idx];
+ var value = test_data[test_names[i]][order_idx][machine_idx];
+ if (baseline === null || value === null)
+ continue;
+
+ pts.push(value / baseline);
+ }
+
+ console.log([subset_name, order_idx, machine_idx, pts]);
+
+ return mean(pts);
+}
+
+AggregateGraphWidget.prototype.compute_plots = function() {
+ // First, compute the metadata on the plots we are generating based on the
+ // current user options.
+ var plot_infos = [{ 'subsets_to_plot' : ["Compile Time"],
+ 'machine_indices_to_plot' : [1] },
+ { 'subsets_to_plot' : ["Execution Time"],
+ 'machine_indices_to_plot' : [1] }];
+
+
+ // For each plot description, compute the plot.
+ var orders = this.oar.data.orders_to_aggregate;
+ this.plots = [];
+ for (var i = 0; i != plot_infos.length; ++i) {
+ var info = plot_infos[i];
+ var pts = [];
+
+ // Add a point for each run order.
+ for (var j = 0; j != orders.length; ++j) {
+ var order = parseInt(orders[j]);
+
+ // Compute the aggregate value for each run in this plot.
+ var values = [];
+ for (var k = 0; k != info.subsets_to_plot.length; ++k) {
+ var subset_name = info.subsets_to_plot[k];
+ for (var l = 0; l != info.machine_indices_to_plot.length; ++l) {
+ var machine_idx = info.machine_indices_to_plot[l];
+ values.push(this.compute_aggregate_for_run(subset_name, j,
+ machine_idx));
+ }
+ }
+
+ // Compute the final value as the mean of the per-run aggregate.
+ var value = mean(values);
+
+ pts.push([order, value]);
+ }
+
+ this.plots.push({
+ label: "Plot " + (i+1).toString(),
+ data: pts,
+ lines: { show: true },
+ points: { show: true }});
+ }
+
+ // Update the plots.
+ var options = {
+ series: { lines: { show: true }, shadowSize: 0 },
+ zoom: { interactive: true },
+ pan: { interactive: true },
+ grid: { hoverable: true }
+ };
+ $.plot(this.graph_elt, this.plots, options);
+}
+
+/* OrderAggregateReport Class */
+
+function OrderAggregateReport(ui_elt_name, data) {
+ this.ui_elt_name = ui_elt_name;
+ this.data = data;
+}
+
+OrderAggregateReport.prototype.init = function() {
+ // Initialize the UI container.
+ this.ui_elt = $("#" + this.ui_elt_name);
+
+ // Add the default graph widget.
+ var widget = new AggregateGraphWidget(this, "oar_graph_widget");
+ widget.init(this.ui_elt);
+ widget.compute_plots();
+
+ return this;
+}
Modified: zorg/trunk/lnt/lnt/server/ui/templates/simple_order_aggregate_report.html
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/simple_order_aggregate_report.html?rev=132156&r1=132155&r2=132156&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/ui/templates/simple_order_aggregate_report.html (original)
+++ zorg/trunk/lnt/lnt/server/ui/templates/simple_order_aggregate_report.html Thu May 26 17:00:53 2011
@@ -8,9 +8,33 @@
{% block title %}Order Aggregate Report{% endblock %}
+{% block head %}
+ <script src="/static/jquery/1.5/jquery.js"></script>
+ <script src="/static/flot/jquery.flot.js"></script>
+ <script src="/static/order_aggregate_ui.js"></script>
+{% endblock %}
+{% block javascript %}
+var g = {};
+
+g.data_table = {{data_table|tojson|safe}};
+g.test_subsets = {{test_subsets|tojson|safe}};
+g.available_machines = {{available_machine_info|tojson|safe}};
+g.orders_to_aggregate = {{orders_to_aggregate|tojson|safe}};
+
+// Register initialization.
+window.onload = function() {
+ new OrderAggregateReport("order_aggregate_report_ui", g).init();
+}
+{% endblock %}
+
{% block body %}
-<h1>Order Aggregate Report</h1>
+<div id="order_aggregate_report_ui"></div>
+
+{# Template code for dumping the data table, for use in debugging. #}
+{#
+
+<h1>Order Aggregate Data</h1>
{% for subset_name,subset_table in data_table|dictsort %}
<h2>{{ subset_name }}</h2>
@@ -46,4 +70,6 @@
{% endfor %}
+#}
+
{% endblock %}
More information about the llvm-commits
mailing list