Commit 067c99ef authored by Jan Kiene's avatar Jan Kiene
Browse files

make y-axis max value adaptive to maximum value in the data

parent 91e3976d
Loading
Loading
Loading
Loading
Loading
+50 −172
Original line number Diff line number Diff line
@@ -486,15 +486,35 @@
    }
  }

  function get_max_y_val_for_plotting(displays, round_to) {
      var max = 0;
      for ( var i = 0; i < displays.length; i++ )
      {
        var data = displays[i].data;
        for ( var j = 0; j < data.length; j++ )
        {
          var val = data[j][1];
          if ( val > max )
          {
            max = val;
          }
        }
      }

      max = Math.ceil( max / round_to ) * round_to;

      return max;
  }

  function WMOPS() {
    		
    var previousPoint = null;

    function drawGraph(elt, graph) {
    function drawGraph(elt, graph, max_val) {
        var options = {
            yaxis: {
                min: 0,
                max: 220,
                max: max_val,
                tickFormatter: function (v, axis) {
                    if (graph.direction == -1)
                        return v + " WMOPS";
@@ -608,7 +628,8 @@
    }

    $(document).ready(function () {
        drawGraph($("#wmops-graph"), Graphs_WMOPS.wmops_worstcase);
        var max = get_max_y_val_for_plotting(Graphs_WMOPS.wmops_worstcase.displays, 50);
        drawGraph($("#wmops-graph"), Graphs_WMOPS.wmops_worstcase, max);
    });

   var refData  = Graphs_WMOPS.wmops_worstcase.displays[0];
@@ -647,11 +668,11 @@ function WMOPS_perOP() {
    		
    var previousPoint = null;

    function drawGraph(elt, graph) {
    function drawGraph(elt, graph, max_val) {
        var options = {
            yaxis: {
                min: 0,
                max: 220,
                max: max_val,
                tickFormatter: function (v, axis) {
                    if (graph.direction == -1)
                        return v + " WMOPS";
@@ -740,7 +761,9 @@ function WMOPS_perOP() {


    $(document).ready(function () {
        drawGraph($("#wmops_per_op-graph"), Graphs_WMOPS_perOP.wmops_worstcase_per_op);
        // need to get worst case of enc + dec combined, because values are stacked in the graph
        var max = get_max_y_val_for_plotting(Graphs_WMOPS.wmops_worstcase.displays, 50);
        drawGraph($("#wmops_per_op-graph"), Graphs_WMOPS_perOP.wmops_worstcase_per_op, max);
    });

    var nEntriesWmopsGraph = Graphs_WMOPS.wmops_worstcase.runs.length - 1;
@@ -761,11 +784,11 @@ function WMOPS_perOP() {
    		
    var previousPoint = null;

    function drawGraph(elt, graph) {
    function drawGraph(elt, graph, max_val) {
        var options = {
            yaxis: {
                min: 0,
                max: 270,
                max: max_val,
                tickFormatter: function (v, axis) {
                    if (graph.direction == -1)
                        return v + " WMOPS";
@@ -879,7 +902,8 @@ function WMOPS_perOP() {
    }

    $(document).ready(function () {
        drawGraph($("#wmops-48kHz-graph"), Graphs_WMOPS_48kHz.wmops_worstcase);
        var max = get_max_y_val_for_plotting(Graphs_WMOPS_48kHz.wmops_worstcase.displays, 50);
        drawGraph($("#wmops-48kHz-graph"), Graphs_WMOPS_48kHz.wmops_worstcase, max);
    });

   var refData  = Graphs_WMOPS_48kHz.wmops_worstcase.displays[0];
@@ -918,11 +942,11 @@ function WMOPS_perOP_48kHz() {
    		
    var previousPoint = null;

    function drawGraph(elt, graph) {
    function drawGraph(elt, graph, max_val) {
        var options = {
            yaxis: {
                min: 0,
                max: 270,
                max: max_val,
                tickFormatter: function (v, axis) {
                    if (graph.direction == -1)
                        return v + " WMOPS";
@@ -1011,7 +1035,9 @@ function WMOPS_perOP_48kHz() {


    $(document).ready(function () {
        drawGraph($("#wmops_per_op-48kHz-graph"), Graphs_WMOPS_perOP_48kHz.wmops_worstcase_per_op);
        // need to get worst case of enc + dec combined, because values are stacked in the graph
        var max = get_max_y_val_for_plotting(Graphs_WMOPS_48kHz.wmops_worstcase.displays, 50);
        drawGraph($("#wmops_per_op-48kHz-graph"), Graphs_WMOPS_perOP_48kHz.wmops_worstcase_per_op, max);
    });

    var nEntriesWmopsGraph = Graphs_WMOPS_48kHz.wmops_worstcase.runs.length - 1;
@@ -1031,11 +1057,11 @@ function RAM() {
    		
    var previousPoint = null;

    function drawGraph(elt, graph) {
    function drawGraph(elt, graph, max_val) {
        var options = {
            yaxis: {
                min: 0,
                max: 280000,
                max: max_val,
                tickFormatter: function (v, axis) {
                    if (graph.direction == -1)
                        return v + " Word";
@@ -1153,7 +1179,8 @@ function RAM() {
    }

    $(document).ready(function () {
        drawGraph($("#ram-graph"), Graphs_RAM.ram_worstcase);
        var max = get_max_y_val_for_plotting(Graphs_RAM.ram_worstcase.displays, 50000);
        drawGraph($("#ram-graph"), Graphs_RAM.ram_worstcase, max);
    });

   var testData = Graphs_RAM.ram_worstcase.displays[1];
@@ -1188,11 +1215,11 @@ function ROM() {
    		
    var previousPoint = null;

    function drawGraph(elt, graph) {
    function drawGraph(elt, graph, max_val) {
        var options = {
            yaxis: {
                min: 0,
                max: 250000,
                max: max_val,
                tickFormatter: function (v, axis) {
                    if (graph.direction == -1)
                        return v + " Word";
@@ -1287,7 +1314,8 @@ function ROM() {
    }

    $(document).ready(function () {
        drawGraph($("#rom-graph"), Graphs_ROM.rom_worstcase);
        var max = get_max_y_val_for_plotting(Graphs_ROM.rom_worstcase.displays, 50000);
        drawGraph($("#rom-graph"), Graphs_ROM.rom_worstcase, max);
    });


@@ -1353,11 +1381,11 @@ function PROM() {
    		
    var previousPoint = null;

    function drawGraph(elt, graph) {
    function drawGraph(elt, graph, max_val) {
        var options = {
            yaxis: {
                min: 0,
                max: 250000,
                max: max_val,
                tickFormatter: function (v, axis) {
                    if (graph.direction == -1)
                        return v + " Ops";
@@ -1453,7 +1481,8 @@ function PROM() {
    }

    $(document).ready(function () {
        drawGraph($("#prom-graph"), Graphs_PROM.prom_worstcase);
        var max = get_max_y_val_for_plotting(Graphs_PROM.prom_worstcase.displays, 50000);
        drawGraph($("#prom-graph"), Graphs_PROM.prom_worstcase, max);
    });


@@ -1510,157 +1539,6 @@ function PROM() {
    }
  }

}


function CONVERSION_FACTORS_perOP(){

    /* deep copy of one of the WMOPS-per-OP objects */
    var Graphs_CONVERSION_FACTORS = jQuery.extend(true, {}, Graphs_WMOPS_BASOP_perOP);

    /* now calculate conversion factors and set the graph-properties
      correctly */

    /* show the points */
    Graphs_CONVERSION_FACTORS.wmops_worstcase_per_op.displays[0].points =
      {show: true};
    Graphs_CONVERSION_FACTORS.wmops_worstcase_per_op.displays[1].points =
      {show: true};


    /* calc conversion factors for encoder */
    for(var i = 0; i<Graphs_CONVERSION_FACTORS.wmops_worstcase_per_op.displays[0].data.length; i++){
      var tmp = Graphs_WMOPS_perOP.wmops_worstcase_per_op.displays[0].data[i][1] / 1.1;
      tmp = Graphs_WMOPS_BASOP_perOP.wmops_worstcase_per_op.displays[0].data[i][1] / tmp;
      tmp = Math.round(tmp * 1000) / 1000;
      Graphs_CONVERSION_FACTORS.wmops_worstcase_per_op.displays[0].data[i][1] = tmp;
    }

    /* calc conversion factors for decoder */
    for(var i = 0; i<Graphs_CONVERSION_FACTORS.wmops_worstcase_per_op.displays[1].data.length; i++){
      var tmp = Graphs_WMOPS_perOP.wmops_worstcase_per_op.displays[1].data[i][1] / 1.1;
      tmp = Graphs_WMOPS_BASOP_perOP.wmops_worstcase_per_op.displays[1].data[i][1] / tmp;
      tmp = Math.round(tmp * 1000) / 1000;
      Graphs_CONVERSION_FACTORS.wmops_worstcase_per_op.displays[1].data[i][1] = tmp;
    }

    /* extend array and set labels/colors correctly*/
    Graphs_CONVERSION_FACTORS.wmops_worstcase_per_op.displays[2] = jQuery.extend(true, {}, Graphs_CONVERSION_FACTORS.wmops_worstcase_per_op.displays[0]);
    Graphs_CONVERSION_FACTORS.wmops_worstcase_per_op.displays[2].color = "#DAA520";
    Graphs_CONVERSION_FACTORS.wmops_worstcase_per_op.displays[2].id = "worstCaseCodec";
    Graphs_CONVERSION_FACTORS.wmops_worstcase_per_op.displays[2].label = "Codec";
    
    /* calc conversion factors for codec */
    for(var i = 0; i<Graphs_CONVERSION_FACTORS.wmops_worstcase_per_op.displays[0].data.length; i++){
      var tmp =
      (Graphs_WMOPS_perOP.wmops_worstcase_per_op.displays[0].data[i][1]
      + Graphs_WMOPS_perOP.wmops_worstcase_per_op.displays[1].data[i][1]) / 1.1;
      tmp =
      (Graphs_WMOPS_BASOP_perOP.wmops_worstcase_per_op.displays[0].data[i][1] + Graphs_WMOPS_BASOP_perOP.wmops_worstcase_per_op.displays[1].data[i][1]) / tmp;
      tmp = Math.round(tmp * 1000) / 1000;
      Graphs_CONVERSION_FACTORS.wmops_worstcase_per_op.displays[2].data[i][1] = tmp;
    }

    var previousPoint = null;

    function drawGraph(elt, graph) {
        var options = {
            yaxis: {
                min: 0,
                max: 2,
                tickFormatter: function (v, axis) {
                    if (graph.direction == -1)
                        return v;
                    return v;
                },
                invert: graph.direction == 1
            },
            xaxis: {
              ticks: graph.ticks
            },
            legend: { show: true },
            grid: {
                hoverable: true,
                clickable: true
            }
        };
		
        $.plot(elt, graph.displays, options);

        elt.bind("plothover", function (event, pos, item) {
        if (!item) {
          $("#tooltip").remove();
          previousPoint = null;
          return;
        }

        if (previousPoint &&
          (previousPoint[0] == item.datapoint[0]) &&
          (previousPoint[1] == item.datapoint[1])) {
            return;
        }

        previousPoint = item.datapoint;
        $("#tooltip").remove();

        var encDataFlc    = Graphs_WMOPS_perOP.wmops_worstcase_per_op.displays[0];
        var decDataFlc    = Graphs_WMOPS_perOP.wmops_worstcase_per_op.displays[1];          
        var encDataBasop  = Graphs_WMOPS_BASOP_perOP.wmops_worstcase_per_op.displays[0];
        var decDataBasop  = Graphs_WMOPS_BASOP_perOP.wmops_worstcase_per_op.displays[1];          

        var x = item.datapoint[0];
        var y = item.datapoint[1];

        var scoreEncFlc   = Math.round((parseFloat(encDataFlc.data[x][1]) / 1.1)*100)/100;
        var scoreDecFlc   = Math.round((parseFloat(decDataFlc.data[x][1]) / 1.1)*100)/100;
        var scoreCodecFlc = Math.round((scoreEncFlc + scoreDecFlc) * 100) / 100;

        var scoreEncBasop   = Math.round(parseFloat(encDataBasop.data[x][1])*100)/100;
        var scoreDecBasop   = Math.round(parseFloat(decDataBasop.data[x][1])*100)/100;
        var scoreCodecBasop = Math.round((scoreEncBasop + scoreDecBasop) * 100) / 100;

        var text = "";

        text += "Mode: " + Graphs_WMOPS_perOP.wmops_worstcase_per_op.runs[x].operatingPoint + "<br><br>";

        text += 'Conversion Factor: ' + Math.round(y * 100) / 100;
        if( item.series.id == "worstCaseEnc" ){
          text += " (enc)";
        } 
        if( item.series.id == "worstCaseDec" ){
          text += " (dec)";
        } 
        text += "<br><br>";

        text += "Worst case enc BASOP: "   + scoreEncBasop + " WMOPS<br>";
        text += "Worst case dec BASOP: "   + scoreDecBasop + " WMOPS<br>";
        text += "Worst case codec BASOP: " + scoreCodecBasop + " WMOPS<br><br>";
      
        text += "Worst case enc Float: "   + scoreEncFlc + " WMOPS<br>";
        text += "Worst case dec Float: "   + scoreDecFlc + " WMOPS<br>";
        text += "Worst case codec Float: " + scoreCodecFlc + " WMOPS<br><br>";
      
        showToolTip(item.pageX, item.pageY, text);
		  
      });

    }		


    $(document).ready(function () {
        drawGraph($("#conversion_factors_basop_flc"), Graphs_CONVERSION_FACTORS.wmops_worstcase_per_op);
    });

    var nEntriesWmopsGraph = Graphs_WMOPS_BASOP.wmops_worstcase.runs.length - 1;
    var legend = "<p style=\"text-align: center;\">Numbers derived from revision " +
                  Graphs_WMOPS_BASOP.wmops_worstcase.runs[nEntriesWmopsGraph].revision + 
                ", " + 
                Graphs_WMOPS_BASOP.wmops_worstcase.runs[nEntriesWmopsGraph].fullDate + 
                "</p>";

    document.getElementById("conversion_factors_basop_flc-legend").innerHTML = legend;


}