コード例 #1
0
def preprocessENwiktionary():
    pa = partitioner(informed = True, dictionary = "../partitioner/dictionaries/enwiktionary.txt")
    pa.dumpqs(qsname="enwiktionary")
コード例 #2
0
ファイル: experiment.py プロジェクト: overrainbow/autoperf
    def run(self, block=False):
        """
        Run the experiment.

        Args:
          block (bool): whether block until the experiment is finished

        Returns:
          None
        """
        print "*** Preparing to run %s" % self.name

        self.insname = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S-%f")

        # logger
        self.logger.info("Run the experiment")
        self.logger.cmd("function run-%s () {", self.insname)
        self.logger.shift()
        # 'cd' actually happens in __init__()
        self.logger.cmd("cd %s\n", self.rootdir)

        # link, copy and build
        self.link_items()
        self.copy_items()
        self.build()

        # partition the metrics
        from partitioner import partitioner
        dbfile = config.get("Partitioner.%s.dbfile" % self.name, "%s.db" % self.platform_name)
        algo   = config.get("Partitioner.%s.algo"   % self.name, "greedy")
        self.parted_metrics = partitioner(dbfile, list(self.metric_set.nmetrics), algo, False)

        # logger
        self.logger.info("Partitioning the metrics:")
        if len(self.parted_metrics) == 0:
            self.logger.critical("CRITICAL: partitioner failed, abort\n")
            # 'cd' actually never happens
            self.logger.cmd("cd %s", self.cwd)
            self.logger.unshift()
            self.logger.cmd( "}")
            raise Exception("Metrics partition failed!")
        for i in range(len(self.parted_metrics)):
            self.logger.info("  %2d: %s", i+1, self.parted_metrics[i])
        self.logger.newline()

        # populate the data directories
        self.logger.info("Populating data directories")
        self.logger.cmd("mkdir -p %s/profiles", self.insname)
        os.makedirs("%s/profiles" % self.insname)

        self.datadirs = [ ]
        for i in range(len(self.parted_metrics)):
            datadir = "%s/.iter-%02d" % (self.insname, i)
            self.datadirs.append(datadir)

            self.logger.cmd("mkdir -p %s/profiles", datadir)
            os.makedirs("%s/profiles" % datadir)

            # pre-link job log and stat marker
            target    = os.path.relpath("%s/job.log" % datadir, self.insname)
            link_name = "%s/job-%02d.log" % (self.insname, i)
            self.logger.cmd("ln -s %s %s", target, link_name)
            os.symlink(target, link_name)
            target    = os.path.relpath("%s/.job.stat" % datadir, self.insname)
            link_name = "%s/.job-%s-%02d.stat" % (self.insname, self.name , i)
            self.logger.cmd("ln -s %s %s", target, link_name)
            os.symlink(target, link_name)

        self.logger.newline()

        # run the experiment
        for i in range(len(self.parted_metrics)):
            self.logger.info("Running experiment, iteration %d of %d",
                             i+1, len(self.parted_metrics))
            self.iteration = i
            self.platform.run(self.execmd, self.exeopt, block)
            self.logger.newline()

        # 'cd' actually happens in cleanup()
        self.logger.cmd("cd %s", self.cwd)
        self.logger.unshift()
        self.logger.cmd( "}")