if firsttime != []:
        for item in firsttime:
            print(bcolors.PURPLE + "First time test! " + item.testname +\
            " Took: " + str(item.real) +  " seconds. Revision: " +\
            item.revision + bcolors.ENDC)


all_files = os.listdir(LOGDIR)
regressed = []
better = []
unchanged = []
firsttime = []

#Go through all log files and find which tests have performed better.
for logfile in all_files:
    (line1, line2) = getLastTwoLines(logfile, LOGDIR)
    log1 = processLogLine(line1)
    if line2 == '\n': # Empty line, only one test ever run
        firsttime.append(log1)
        continue
    log2 = processLogLine(line2)
    res = Result(log1.testname, log1.real, log2.real, log2.revision,\
    log2.branch, log1.revision, log1.branch)
    if res.percentage < -PERCENTAGE:
        regressed.append(res)
    elif res.change > PERCENTAGE:
        better.append(res)
    else:
        unchanged.append(res)

printResults(regressed, better, unchanged, firsttime)
Exemple #2
0
def produce_html(path, global_config):
    """Produces html file for the report."""
    html = ''  #The table HTML
    for filenam in os.listdir(global_config.testlogs):
        #Generate html for the newest two lines
        #Get the lines from the config file
        (ll1, ll2) = getLastTwoLines(filenam, global_config.testlogs)
        logLine1 = processLogLine(ll1)
        logLine2 = processLogLine(ll2)

        #Generate html
        res1 = Result(logLine1.testname, logLine1.real, logLine2.real,\
            logLine2.revision, logLine2.branch, logLine1.revision, logLine1.branch)
        html = html + '<tr><td>' + logLine2.date + '</td><td>' + logLine2.time + '</td><td>' +\
        res1.testname + '</td><td>' + res1.revision[:10] + '</td><td>' + res1.branch + '</td><td>' +\
        str(res1.current) + '</td><td>' + str(res1.previous) + '</td><td>' + res1.prevrev[:10] + '</td>'

        #Add fancy colours depending on the change
        if res1.percentage > 0.05:  #If we have improvement of more than 5%
            html = html + '<td class="better">' + str(
                res1.percentage) + '</td>'
        elif res1.percentage < -0.05:  #We have a regression of more than 5%
            html = html + '<td class="worse">' + str(res1.percentage) + '</td>'
        else:
            html = html + '<td class="unchanged">' + str(
                res1.percentage) + '</td>'

        #Get comparison against the base version
        filenam = global_config.testlogs + '/' + filenam  #Get proper directory
        res2 = compare_rev(filenam,
                           global_config.basebranch,
                           res1.revision,
                           branch1=True)
        html = html + '<td>' + str(res2.previous) + '</td>'

        #Add fancy colours depending on the change
        if res2.percentage > 0.05:  #If we have improvement of more than 5%
            html = html + '<td class="better">' + str(
                res2.percentage) + '</td>'
        elif res2.percentage < -0.05:  #We have a regression of more than 5%
            html = html + '<td class="worse">' + str(res2.percentage) + '</td>'
        else:
            html = html + '<td class="unchanged">' + str(
                res2.percentage) + '</td>'

        #Add extra dates comparison dating from the beginning of time if they exist
        past_dates = list(range(2, 8))
        past_dates.append(14)
        past_dates.append(365)  # Get the 1 year ago day
        linesdict = gather_necessary_lines(filenam, logLine2.date)

        for days in past_dates:
            act_date = get_prev_days(logLine2.date, days)
            if linesdict[act_date][1] is not None:
                logline_date = linesdict[act_date][1]
                restemp = Result(logline_date.testname, logline_date.real, logLine2.real,\
                logLine2.revision, logLine2.branch, logline_date.revision, logline_date.branch)
                html = html + append_date_to_table(restemp)
            else:
                html = html + '<td>N/A</td><td>N/A</td>'

        html = html + '</tr>'  #End row

    #Write out the file
    basebranch_info = '<text><b>Basebranch:</b> ' + res2.prevbranch + ' <b>Revision:</b> ' +\
    res2.prevrev + '</text>'
    writeoutstr = HTML_HEADING + basebranch_info + TABLE_HEADING + html + HTML_ENDING
    writefile = open(path, 'w')
    writefile.write(writeoutstr)
    writefile.close()
Exemple #3
0
def produce_html(path, global_config):
    """Produces html file for the report."""
    html = '' #The table HTML
    for filenam in os.listdir(global_config.testlogs):
        #Generate html for the newest two lines
        #Get the lines from the config file
        (ll1, ll2) = getLastTwoLines(filenam, global_config.testlogs)
        logLine1 = processLogLine(ll1)
        logLine2 = processLogLine(ll2)

        #Generate html
        res1 = Result(logLine1.testname, logLine1.real, logLine2.real,\
            logLine2.revision, logLine2.branch, logLine1.revision, logLine1.branch)
        html = html + '<tr><td>' + logLine2.date + '</td><td>' + logLine2.time + '</td><td>' +\
        res1.testname + '</td><td>' + res1.revision[:10] + '</td><td>' + res1.branch + '</td><td>' +\
        str(res1.current) + '</td><td>' + str(res1.previous) + '</td><td>' + res1.prevrev[:10] + '</td>'

        #Add fancy colours depending on the change
        if res1.percentage > 0.05: #If we have improvement of more than 5%
            html = html +  '<td class="better">' + str(res1.percentage) + '</td>'
        elif res1.percentage < -0.05: #We have a regression of more than 5%
            html = html +  '<td class="worse">' + str(res1.percentage) + '</td>'
        else:
            html = html +  '<td class="unchanged">' + str(res1.percentage) + '</td>'

        #Get comparison against the base version
        filenam = global_config.testlogs + '/' + filenam #Get proper directory
        res2 = compare_rev(filenam, global_config.basebranch, res1.revision, branch1=True)
        html = html + '<td>' + str(res2.previous) + '</td>'

        #Add fancy colours depending on the change
        if res2.percentage > 0.05: #If we have improvement of more than 5%
            html = html +  '<td class="better">' + str(res2.percentage) + '</td>'
        elif res2.percentage < -0.05: #We have a regression of more than 5%
            html = html +  '<td class="worse">' + str(res2.percentage) + '</td>'
        else:
            html = html +  '<td class="unchanged">' + str(res2.percentage) + '</td>'

        #Add extra dates comparison dating from the beginning of time if they exist
        past_dates = list(range(2, 8))
        past_dates.append(14)
        past_dates.append(365) # Get the 1 year ago day
        linesdict = gather_necessary_lines(filenam, logLine2.date)

        for days in past_dates:
            act_date = get_prev_days(logLine2.date, days)
            if linesdict[act_date][1] is not None:
                logline_date = linesdict[act_date][1]
                restemp = Result(logline_date.testname, logline_date.real, logLine2.real,\
                logLine2.revision, logLine2.branch, logline_date.revision, logline_date.branch)
                html = html + append_date_to_table(restemp)
            else:
                html = html + '<td>N/A</td><td>N/A</td>'



        html = html + '</tr>' #End row

    #Write out the file
    basebranch_info = '<text><b>Basebranch:</b> ' + res2.prevbranch + ' <b>Revision:</b> ' +\
    res2.prevrev + '</text>'
    writeoutstr = HTML_HEADING + basebranch_info + TABLE_HEADING + html + HTML_ENDING
    writefile = open(path, 'w')
    writefile.write(writeoutstr)
    writefile.close()