var fs = require("fs"); var generatePerfReportXML = function (reportName, testdata) { 'use strict'; var x = '\n' + '\n' + ' \n'; //// TODO: zeit einsetzen. for (var testname in testdata) { if (testdata.hasOwnProperty(testname)) { for (var testCalculation in testdata[testname]) { if (testdata[testname].hasOwnProperty(testCalculation) && (testCalculation !== 'status')) { var s = testdata[testname][testCalculation].duration; x = x + '\t\n'; x = x + '\t\t\n'; x = x + '\t\t\n\t\t\tAQL\n\t\t\n'; x += '\t\tSum time\n'; x = x + '\t\t\n'; x += '\t\t\t\n'; x += '\t\t\t\n'; x += '\t\t\t\n'; x += '\t\t\t\n'; x += '\t\t\n'; x = x + '\t\n'; } } } } x = x + '\n\n'; fs.write(reportName + ".xml", x); }; var generatePerfReportGrinderCSV = function (reportName, testdata) { 'use strict'; var x = "Thread, Run, Test 1, Start time (ms since Epoch), Test time, Errors, TPS , HTTP response length, HTTP response errors, Time to resolve host, Time to establish connection, Time to first byte, New connections"; for (var testname in testdata) { if (testdata.hasOwnProperty(testname)) { for (var testCalculation in testdata[testname]) { if (testdata[testname].hasOwnProperty(testCalculation) && (testCalculation !== 'status')) { var s = testdata[testname][testCalculation].duration; if (!isNaN(s)) { x = x + '\n0, 0, ' + testname + '/' + testCalculation + ',' + Math.floor(require("internal").time()*1000) + ', ' + Math.floor(s*1000) + ', 0, 0, 0, 0, 0, 0, 0, 0'; } } } } } fs.write("out_" + reportName + "_perftest.log", x); }; var generatePerfReportJTL = function(reportName, testdata) { var testFileName = "out_" + reportName + "_perftest.jtl"; var x = '\n\n'; for (var testname in testdata) { if (testdata.hasOwnProperty(testname)) { for (var testCalculation in testdata[testname]) { if (testdata[testname].hasOwnProperty(testCalculation) && (testCalculation !== 'status')) { var s = testdata[testname][testCalculation].duration; if (!isNaN(s)) { x = x + '\n' } } } } } x = x + ''; fs.write(testFileName, x); } exports.reportGeneratorXML = generatePerfReportXML; exports.generatePerfReportGrinderCSV = generatePerfReportGrinderCSV; exports.generatePerfReportJTL = generatePerfReportJTL;