Example #1
0
    algorithms = [
        Maze.Solve.C,
        Maze.Solve.DEPTH,
        Maze.Solve.BREADTH
    ]

    index = cli.menu("Which algorithm do you want to use?", *[algorithm.value for algorithm in algorithms], result=True)
    algorithm = algorithms[index]

    cli.line()

    print("Loading maze...")
    sw.start()
    m.load_maze()
    sw.stop()
    print(sw.elapsed_str)

    cli.line()

    print("Solving maze...")
    sw.start()
    m.solve((), (), algorithm)
    sw.stop()
    print(sw.elapsed_str)

    cli.line()
    print("Saving solution...")
    sw.start()
    m.save_solution()
    sw.stop()
Example #2
0
print "Python"

n = 1001
maxtime = 2.0 
a =0.99 

x= np.zeros(n, dtype=float)

x[0]=x[int(n/2)]= x[n-1]= 1.0 

nsmooth=0
y= np.zeros(n, dtype=float)

sw.start()
while sw.time() < maxtime :
    dsp.smooth(a,x,y)
    nsmooth+=1
sw.stop()

print "nsmooth = %d "%nsmooth
print "   mean = %9.7f "%dsp.mean(y)
print "   time = %9.7f "%sw.time()
print " mflops = %f "%((6.0e-6*n*nsmooth/sw.time()))



if plot:
    ll = plt.plot(range(n),y)
    plt.show()
Example #3
0
def build_all(r, build_fnc):
    status.email = r.requester_email
    notify.begin(r)
    tmp = path.build_dir + '/' + util.uuid() + "/"
    r.tmp_dir = tmp
    os.mkdir(tmp)
    atexit.register(util.clean_tmp, tmp)

    log.notice("started processing %s" % r.id)
    r.chroot_files = []
    r.some_ok = 0
    for batch in r.batches:
        can_build = 1
        failed_dep = ""
        for dep in batch.depends_on:
            if dep.build_failed:
                can_build = 0
                failed_dep = dep.spec

        if batch.is_command() and can_build:
            batch.logfile = tmp + "command"
            if config.builder in batch.builders:
                log.notice("running %s" % batch.command)
                stopwatch.start()
                batch.build_failed = run_command(batch)
                if batch.build_failed:
                    log.notice("running %s FAILED" % batch.command)
                    notify.add_batch(batch, "FAIL")
                else:
                    r.some_ok = 1
                    log.notice("running %s OK" % batch.command)
                    notify.add_batch(batch, "OK")
                batch.build_time = stopwatch.stop()
                report.add_pld_builder_info(batch)
                buildlogs.add(batch.logfile, failed = batch.build_failed, id=r.id)
            else:
                log.notice("not running command, not for me.")
                batch.build_failed = 0
                batch.log_line("queued command %s for other builders" % batch.command)
                r.some_ok = 1
                buildlogs.add(batch.logfile, failed = batch.build_failed, id=r.id)
        elif can_build:
            log.notice("building %s" % batch.spec)
            stopwatch.start()
            batch.logfile = tmp + batch.spec + ".log"
            batch.gb_id=r.id
            batch.requester=r.requester
            batch.requester_email=r.requester_email
            batch.build_failed = build_fnc(r, batch)
            if batch.build_failed:
                log.notice("building %s FAILED (%s)" % (batch.spec, batch.build_failed))
                notify.add_batch(batch, batch.build_failed)
            else:
                r.some_ok = 1
                log.notice("building %s OK" % (batch.spec))
                notify.add_batch(batch, "OK")
            batch.build_time = stopwatch.stop()
            report.add_pld_builder_info(batch)
            buildlogs.add(batch.logfile, failed = batch.build_failed, id=r.id)
        else:
            batch.build_failed = 1
            batch.skip_reason = "SKIPED [%s failed]" % failed_dep
            batch.logfile = None
            batch.build_time = ""
            log.notice("building %s %s" % (batch.spec, batch.skip_reason))
            notify.add_batch(batch, "SKIP")

    buildlogs.flush()
    chroot.run("rm -f %s" % string.join(r.chroot_files))
Example #4
0
def build_all(r, build_fnc):
    status.email = r.requester_email
    notify.begin(r)
    tmp = path.build_dir + '/' + util.uuid() + "/"
    r.tmp_dir = tmp
    os.mkdir(tmp)
    atexit.register(util.clean_tmp, tmp)

    log.notice("started processing %s" % r.id)
    r.chroot_files = []
    r.some_ok = 0
    for batch in r.batches:
        can_build = 1
        failed_dep = ""
        for dep in batch.depends_on:
            if dep.build_failed:
                can_build = 0
                failed_dep = dep.spec

        if batch.is_command() and can_build:
            batch.logfile = tmp + "command"
            if config.builder in batch.builders:
                log.notice("running %s" % batch.command)
                stopwatch.start()
                batch.build_failed = run_command(batch)
                if batch.build_failed:
                    log.notice("running %s FAILED" % batch.command)
                    notify.add_batch(batch, "FAIL")
                else:
                    r.some_ok = 1
                    log.notice("running %s OK" % batch.command)
                    notify.add_batch(batch, "OK")
                batch.build_time = stopwatch.stop()
                report.add_pld_builder_info(batch)
                buildlogs.add(batch.logfile,
                              failed=batch.build_failed,
                              id=r.id)
            else:
                log.notice("not running command, not for me.")
                batch.build_failed = 0
                batch.log_line("queued command %s for other builders" %
                               batch.command)
                r.some_ok = 1
                buildlogs.add(batch.logfile,
                              failed=batch.build_failed,
                              id=r.id)
        elif can_build:
            log.notice("building %s" % batch.spec)
            stopwatch.start()
            batch.logfile = tmp + batch.spec + ".log"
            batch.gb_id = r.id
            batch.requester = r.requester
            batch.requester_email = r.requester_email
            batch.build_failed = build_fnc(r, batch)
            if batch.build_failed:
                log.notice("building %s FAILED (%s)" %
                           (batch.spec, batch.build_failed))
                notify.add_batch(batch, batch.build_failed)
            else:
                r.some_ok = 1
                log.notice("building %s OK" % (batch.spec))
                notify.add_batch(batch, "OK")
            batch.build_time = stopwatch.stop()
            report.add_pld_builder_info(batch)
            buildlogs.add(batch.logfile, failed=batch.build_failed, id=r.id)
        else:
            batch.build_failed = 1
            batch.skip_reason = "SKIPED [%s failed]" % failed_dep
            batch.logfile = None
            batch.build_time = ""
            log.notice("building %s %s" % (batch.spec, batch.skip_reason))
            notify.add_batch(batch, "SKIP")

    buildlogs.flush()
    chroot.run("rm -f %s" % string.join(r.chroot_files))