예제 #1
0
import sys
import os
from gumby.settings import loadConfig
from gumby.spectraperf.performanceprofile import SessionHelper

if __name__ == '__main__':

    if len(sys.argv) < 5:
        print "Usage: python store_run_in_database.py configFile csvPath revision testcase"
        sys.exit(0)

    config = loadConfig(os.path.abspath(sys.argv[1]))

    # DATABASE = os.path.abspath("../database/performance.db")
    print "Setting database: %s " % config['spectraperf_db_path']
    DATABASE = os.path.abspath(config['spectraperf_db_path'])

    csvPath = sys.argv[2]
    revision = sys.argv[3]
    testcase = sys.argv[4]

    if not os.path.isfile(csvPath):
        print "Not a valid CSV file"
        sys.exit(0)

    helper = SessionHelper(config)
    sess1 = helper.loadSessionFromCSV(revision, testcase, csvPath)
    helper.appendData(sess1, csvPath.replace("summary_per_stacktrace.csv", "summary.txt"))
    helper.storeInDatabase(sess1)
    print "Run stored"
    profileHelper = ProfileHelper(config)
    p = profileHelper.loadFromDatabase(prevRevision, testcase)

    if p != -1:
        output = ""

        matrix = ActivityMatrix(p.getDatabaseId(), 5, Type.BYTESWRITTEN, rev, testcase)

        for i in range(1, 6):
            helper = SessionHelper(config)
            csv = "%s/report_%s_%d/summary_per_stacktrace.csv" % (csvPath, rev, i)
            csvExtra = "%s/report_%s_%d/summary.txt" % (csvPath, rev, i)
            if not os.path.isfile(csv):
                print "Not a valid CSV file: %s" % csv
                continue
            sess = helper.loadSessionFromCSV(rev, testcase, csv)
            sess.isTestRun = 1
            helper.appendData(sess, csvExtra)
            helper.storeInDatabase(sess)

            fits = p.fitsProfile(sess)
            sim = p.similarity(fits)
            metricValue = p.similarity(fits)
            matrix.addFitsVector(fits)

            helper.storeMetricInDatabase(sess, metricValue)
            output += "------------------------\n%s\n" % csv
            output += "Metric: cosine sim, value: %f\n" % metricValue.value

        # print output
        matrix.calcSimilarity()
import os
from gumby.settings import loadConfig
from gumby.spectraperf.performanceprofile import SessionHelper

if __name__ == '__main__':

    if len(sys.argv) < 5:
        print "Usage: python store_run_in_database.py configFile csvPath revision testcase"
        sys.exit(0)

    config = loadConfig(os.path.abspath(sys.argv[1]))

    # DATABASE = os.path.abspath("../database/performance.db")
    print "Setting database: %s " % config['spectraperf_db_path']
    DATABASE = os.path.abspath(config['spectraperf_db_path'])

    csvPath = sys.argv[2]
    revision = sys.argv[3]
    testcase = sys.argv[4]

    if not os.path.isfile(csvPath):
        print "Not a valid CSV file"
        sys.exit(0)

    helper = SessionHelper(config)
    sess1 = helper.loadSessionFromCSV(revision, testcase, csvPath)
    helper.appendData(
        sess1, csvPath.replace("summary_per_stacktrace.csv", "summary.txt"))
    helper.storeInDatabase(sess1)
    print "Run stored"