Beispiel #1
0
    def __prompt_display_name(self):
        self.display_name = raw_input("Name: ").strip()

        found = False
        for framework in gather_frameworks(config=self.benchmarker_config):
            if framework.lower() == self.display_name.lower():
                found = True

        if found:
            print("""
  It appears that there is already a '%s' framework in the test suite. You will
  have to pick a different name.
      """ % self.display_name)
            self.display_name = None
Beispiel #2
0
    def __count_sloc(self):
        '''
        Counts the significant lines of code for all tests and stores in results.
        '''
        frameworks = gather_frameworks(self.config.test, self.config.exclude,
                                       self.config)

        jsonResult = {}
        for framework, testlist in frameworks.items():
            if not os.path.exists(
                    os.path.join(testlist[0].directory, "source_code")):
                log("Cannot count lines of code for %s - no 'source_code' file"
                    % framework)
                continue

            # Unfortunately the source_code files use lines like
            # ./cpoll_cppsp/www/fortune_old instead of
            # ./www/fortune_old
            # so we have to back our working dir up one level
            wd = os.path.dirname(testlist[0].directory)

            try:
                command = "cloc --list-file=%s/source_code --yaml" % testlist[
                    0].directory

                if os.path.exists(
                        os.path.join(testlist[0].directory, "cloc_defs.txt")):
                    command += " --read-lang-def %s" % os.path.join(
                        testlist[0].directory, "cloc_defs.txt")
                    log("Using custom cloc definitions for %s" % framework)

                # Find the last instance of the word 'code' in the yaml output. This should
                # be the line count for the sum of all listed files or just the line count
                # for the last file in the case where there's only one file listed.
                command = command + "| grep code | tail -1 | cut -d: -f 2"
                log("Running \"%s\" (cwd=%s)" % (command, wd))
                lineCount = subprocess.check_output(command,
                                                    cwd=wd,
                                                    shell=True)
                jsonResult[framework] = int(lineCount)
            except subprocess.CalledProcessError:
                continue
            except ValueError as ve:
                log("Unable to get linecount for %s due to error '%s'" %
                    (framework, ve))
        self.rawData['slocCounts'] = jsonResult
Beispiel #3
0
    def __count_commits(self):
        '''
        Count the git commits for all the framework tests
        '''
        frameworks = gather_frameworks(self.config.test, self.config.exclude,
                                       self.config)

        def count_commit(directory, jsonResult):
            command = "git rev-list HEAD -- " + directory + " | sort -u | wc -l"
            try:
                commitCount = subprocess.check_output(command, shell=True)
                jsonResult[framework] = int(commitCount)
            except subprocess.CalledProcessError:
                pass

        # Because git can be slow when run in large batches, this
        # calls git up to 4 times in parallel. Normal improvement is ~3-4x
        # in my trials, or ~100 seconds down to ~25
        # This is safe to parallelize as long as each thread only
        # accesses one key in the dictionary
        threads = []
        jsonResult = {}
        # t1 = datetime.now()
        for framework, testlist in frameworks.items():
            directory = testlist[0].directory
            t = threading.Thread(
                target=count_commit, args=(directory, jsonResult))
            t.start()
            threads.append(t)
            # Git has internal locks, full parallel will just cause contention
            # and slowness, so we rate-limit a bit
            if len(threads) >= 4:
                threads[0].join()
                threads.remove(threads[0])

        # Wait for remaining threads
        for t in threads:
            t.join()
        # t2 = datetime.now()
        # print "Took %s seconds " % (t2 - t1).seconds

        self.rawData['commitCounts'] = jsonResult
        self.config.commits = jsonResult