def buildNotebook(appName, result, notebookPath, dataFilePath, runId): """ Method to build .ipynb notebook with init code cell for profiles and one report cell per category. """ begin = time.time() LOGGER.info('generating notebook %s -> ', os.path.basename(notebookPath)) nb = nbf.new_notebook() numOfCategories, d3Flots = buildReportCells(nb, result, dataFilePath) buildInitCell(nb, numOfCategories, d3Flots, appName, runId) try: with open(notebookPath, 'w') as reportFile: nbformat.write(nb, reportFile) notebookSize = formatHumanReadable(os.path.getsize(notebookPath)) elapsed = time.time() - begin LOGGER.completed('completed %s in %0.2f sec.', notebookSize, elapsed) return True except IOError: LOGGER.exception('Could not write to the notebook(.ipynb) file') return False
def generateLatencyReports(self, profiles, flots, result, resultOrder, reportThreshold): """ Generates latency breakup reports for a list of profiles :param profiles: Profile data for the current profile session :param flots: Latency distribuion histograms for each category/route combination :param result: Handle to gather and store profiling results :param resultOrder: Sort order of transactions in latency constituent reports :param reportThreshold: Threshold for number of transactions rendered in html reports. """ flotTracker = set() for profile in profiles: begin = time.time() reportTitle = '{} latency statistics [{} transactions]'.format( profile.name, len(profile.current)) LOGGER.info('generating report %s -> ', reportTitle) category = profile.category if category not in flotTracker and category in flots: flots[category].attach(result) flotTracker.add(category) self.addTestResult(profile.name, result, profile.current, profile.benchmarks) report = ReportBuilder().buildReport(profile.current, profile.benchmarks, profile.reportProbes, profile.name, resultOrder, reportThreshold) reportSize = formatHumanReadable(len(report)) reportTitle = '{} - ({})'.format(reportTitle, reportSize) description = '\n\t{}\n\t'.format(reportTitle) elapsed = time.time() - begin LOGGER.completed('completed %s in %0.2f sec.', reportSize, elapsed) result.attachXpediteReport(profile.name, reportTitle, description, report)