416DAT

Artifact Content
Login

Artifact 6844825f309f373a137df11a4dc203b9986bdb18:


	//draw the throughput/number of nodes graph - Load
	function drawLoadThroughput() {
		var data = google.visualization.arrayToDataTable([
			['numNodes', 'Cassandra', 'MongoDB', 'Couchbase', 'Redis', 'OrientDB'],
			['1',		4161,	    1771,	3942,	    6422,	52],
			['5',		8053,	    1280,	5123,	    5998,	49]
		]);

		var options = {
			'title': 'Throughput Results - Load process',
			'hAxis': {title: "Shards"},
			'vAxis': {title: "Throughput(operations/sec)"},
			'pointSize':2
		};

		//Create and draw the chart.
		new google.visualization.LineChart(document.getElementById('chart_div_throughput')).draw(data, options);
	}

	//draw the throughput/number of nodes graph - Run A
	function drawRunAThroughput() {
		var data = google.visualization.arrayToDataTable([
			['numNodes', 'Cassandra', 'MongoDB', 'Couchbase', 'Redis', 'OrientDB'],
			['1',		2043,	    2341,	855,	    9614,	718],
			['5',		5201,	    1791,	833,	    9054,	364]
		]);

		var options = {
			'title': 'Throughput Results - Read-mostly Workload',
			'hAxis': {title: "Shards"},
			'vAxis': {title: "Throughput(operations/sec)"},
			'pointSize':2
		};

		//Create and draw the chart.
		new google.visualization.LineChart(document.getElementById('chart_div_throughputA')).draw(data, options);
	}

	//draw the throughput/number of nodes graph - Run D
	function drawRunDThroughput() {
		var data = google.visualization.arrayToDataTable([
			['numNodes', 'Cassandra', 'MongoDB',  'Redis', 'OrientDB'],
			['1',		2242,	    5084,	8728,	568],
			['5',		5591,	    2147,	9777,	399]
		]);

		var options = {
			'colors': ['#3366cc','#dc3912','#109618','#990099'],
			'title': 'Throughput Results - Read-latest Workload',
			'hAxis': {title: "Shards"},
			'vAxis': {title: "Throughput(operations/sec)"},
			'pointSize':2
		};

		//Create and draw the chart.
		new google.visualization.LineChart(document.getElementById('chart_div_throughputD')).draw(data, options);
	}

    //generates a data table
    function createDataTable(csv,graphLatency) {

      // Create the data table.
      var dataTable = new google.visualization.DataTable();

      dataTable.addColumn('number', 'ElapsedTime');
      if(graphLatency==false){
        dataTable.addColumn('number', 'TotalOps');
      } else {
        dataTable.addColumn('number', 'AverageLatency');
      }
      addLinesToDataTable(dataTable, csv, graphLatency);

      return dataTable;
    }

    //draws a chart

    function drawLineChart(dataTable,graphLatency) {
      // Set chart options
      var options;


          //'width': 1000,
          //'height': 800,
      if(graphLatency==false){
        options = {
          'title': 'Total Operation Performance',
          'hAxis': {title: "Elapsed Seconds"},
          'vAxis': {title: "Total Operations"},
          'pointSize':2
        };

      } else {
        options = {
          'title': 'Latency Performance',
          'hAxis': {title: "Elapsed Seconds"},
          'vAxis': {title: "Average Latency"},
          'pointSize':2,
          'colors' : ['#C00000' , '#FF00FF']
        };
      }

      // Instantiate and draw our chart, passing in some options.
      if(graphLatency==false){
        var chart = new google.visualization.LineChart(document.getElementById('chart_div_line'));
        chart.draw(dataTable, options);
      } else {
        var chart = new google.visualization.ScatterChart(document.getElementById('chart_div_scatter'));
        chart.draw(dataTable, options);        
      }
    }

    //add lines to a data table
    //expects 2 columns of integers

    function addLinesToDataTable(dataTable, csv, graphLatency) {
      var lines = csv.split("\n");
      for (var j = 0; j < lines.length; j++) {
        var line = lines[j];
        if (!line.match(/sec/)) {
          continue;
        }

        var rowObj = [];
        var values = line.split(',');
        var extractedVal;
        //0.458 sec: 35 operations; 118.81 current ops/sec; [INSERT AverageLatency(us)=8053.08] 
          //elapsed seconds
        extractedVal = extractElapsedSecondsInt(values[0]);
        console.log("The elapsed seconds are " + extractedVal + "\n");
        rowObj.push(extractedVal);

        if (graphLatency==false) {
          //graph total ops
          extractedVal = extractTotalOpsInt(values[1]);
          console.log("The total ops are " + extractedVal + "\n");
          rowObj.push(extractedVal);
        } else {//latency
          if(values.length!=4){
            //at the start of the status logging there is nothing recorded for latency
            continue;
          }
          extractedVal = extractLatencyInt(values[3]);
          console.log("The latency is  " + extractedVal + "\n");
          rowObj.push(extractedVal);
        }
        
        dataTable.addRow(rowObj);
      } // end add rows
      return dataTable;
    }
 
   function extractLatencyInt (val) {
      var averageLatencyInt = parseInt(val.trim().slice(27,-1));
      return averageLatencyInt;
    }

    function extractTotalOpsInt(val) {
      var totalOpsInt = parseInt(val.trim().slice(0, -11));
      return totalOpsInt;
    }

    function extractElapsedSecondsInt(val) {
      var elpSecInt = parseInt(val.trim().slice(0, -3));
      return elpSecInt;
    }

    function determineChartsToLoad() {
      var chartsURI = [];
      chartsURI.push(cassLoad100kStatus.dat);
    }

    function fetchDataDrawChart(graphLatency,file) {
	console.log("filename is " + file);
     $.ajax({
        url: file,
        cache: false
      }).done(function(csv) {
        var dataTable= createDataTable(csv,graphLatency);
        drawLineChart(dataTable,graphLatency);
	  if(graphLatency==true){
	  //    fetchDataDrawChart(false,file)
	  }
      });
    }

function drawCharts(file){
    console.log(file);
    fetchDataDrawChart(true,file);
    fetchDataDrawChart(false,file);
}