当前位置: 首页>>代码示例>>Python>>正文


Python Stats.instance方法代码示例

本文整理汇总了Python中stats.Stats.instance方法的典型用法代码示例。如果您正苦于以下问题:Python Stats.instance方法的具体用法?Python Stats.instance怎么用?Python Stats.instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stats.Stats的用法示例。


在下文中一共展示了Stats.instance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from stats import Stats [as 别名]
# 或者: from stats.Stats import instance [as 别名]
    def run(self, run_id):
        # queue input into the write input slot,
        # execute oprator if all inputs are available
        if not self.ready(): return

        newinputs = map(ArrayStore.instance().get, self.slots)
        inputshapes = [arr.shape for arr in newinputs]
        self.inputs[run_id] = list(self.slots)
        self.slots = [None] * self.nargs

        wlog.info('%s.run(%d)', self.op, run_id)
        pstore = self.op.pstore(run_id)


        start = time.time()        
        output, stats = self.op.run(newinputs, run_id)
        runtime = time.time() - start

        newinputs = None

        # calculate runtime and provenance overheads
        pstore.close()

        if pstore.get_stat('write') > 0:
            for f in ('outcache', 'incache', 'serin', 'serout', 'mergcost', 'bdbcost',
                      'keycost', 'idxcost', 'write', 'flush'):
                wlog.debug( "%s\t%f", f, pstore.get_stat(f) )

        # store outputs
        outputid = ArrayStore.instance().add(output)
        outputshape = output.shape
        del output
        self.outputs[run_id] = outputid
        outputdisk = ArrayStore.instance().size(outputid)

        Stats.instance().add_wrun(run_id, self.op, runtime, inputshapes, outputshape, outputdisk, pstore)
        return outputid
开发者ID:sirrice,项目名称:pstore,代码行数:39,代码来源:op.py

示例2: exit

# 需要导入模块: from stats import Stats [as 别名]
# 或者: from stats.Stats import instance [as 别名]
          """
    exit()

dbname = './_output/pablostats.db'
runmodes = []
for arg in sys.argv:
    if '.db' in arg:
        dbname = arg
    else:
        try:
            runmode = int(arg)
            runmodes.append(runmode)
        except:
            pass

stats = Stats.instance(dbname)
conn = stats.conn
cur = conn.cursor()


def get_exps(runmode):
    # get all the experiments
    cur.execute("""select rowid, runmode, runtype, width, height, diskconstraint, runconstraint
                from exec where runmode = ? and
                runtype not in ('noop', 'noop_model', 'stats', 'stats_model', 'opt', 'noop_m', 'stats_m')
                order by rowid, diskconstraint""", (runmode,))
    return cur.fetchall()

def get_labels(exps):
    replaces = (('KEY', 'REF'), ('PTR_', '3_'), ('_B', '_b'), ('_F', '_f'), ('PTMAP_', '2_')
                )
开发者ID:sirrice,项目名称:pstore,代码行数:33,代码来源:gen_lsst_summary.py

示例3: run_nlp

# 需要导入模块: from stats import Stats [as 别名]
# 或者: from stats.Stats import instance [as 别名]
def run_nlp(stats, w, mp, maxdisk, maxoverhead):
    """
    maxoverhead is percentage of average runtime cost of optimizable operators
    """
    stats = Stats.instance()
    ops = w.get_optimizable_ops()
    mapops = [op for op in ops if Mode.FULL_MAPFUNC in op.supported_modes()]
    ops = [op for op in ops if Mode.FULL_MAPFUNC not in op.supported_modes()]
    matstrats = w.get_matstrats()
    currun = w._runid
    pairs = [(currun, op, s) for op in ops for s in matstrats]

    trips = list(pairs)
    existingops = []
    for r,o,s in Runtime.instance().get_disk_strategies():
        trips.append((r,o,s))
        trips.append((r,o,Strat.query()))
        existingops.append((o,r))

    xold = [Runtime.instance().check_strategy(op,r,s) and 1 or 0 for r,op,s in trips]

    avg_runtime = sum(filter(lambda x: x > 0, [mp.get_opcost(op, s) for r,op,s in pairs if r == currun]))
    maxoverhead *= avg_runtime

    G1 = []
    G1dict = {}
    for r,op,s in trips:
        if op not in G1dict:
            G1dict[op] = []
        if r == currun:
            disk = mp.get_disk(op, s)
        else:
            disk = stats.get_disk(r,op,s)
        G1.append(disk)
        if disk > 0:
            G1dict[op].append(disk)
    G2 = []
    G2dict = {}
    for r,op,s in trips:
        if op not in G2dict:
            G2dict[op] = []
        if r == currun:
            ov = mp.get_provcost(op, s)
        else:
            ov = 0.0
        G2.append(ov)
        if ov > 0:
            G2dict[op].append(ov)


    
    G = matrix([G1, G2]).trans()
    h = matrix([maxdisk, maxoverhead])

    A = []
    # every operator needs exactly 1 strategy constraint
    blocksize = len(matstrats) 
    for i in xrange(len(ops)):
        row = [0.0] * len(trips)
        for col in xrange(len(trips)):
            if blocksize * i <= col and col < blocksize * (i+1) and col < len(pairs):
                row[col] = 1.0
        A.append(row)
    for i, (op,r) in enumerate(existingops):
        row = [0.0] * len(trips)
        col = len(pairs) + i * 2
        row[col] = 1.0
        row[col+1] = 1.0
        A.append(row)
    A = matrix(A).trans()
    b = matrix([1.0] * (len(ops)+len(existingops)))

    c = []
    mincs = {}
    for r,op,s in trips:
        cost = mp.get_pqcost(op,s,r)
        c.append(cost)
        if cost > 0 and op not in mincs:
            mincs[op] = cost
        if cost > 0 and cost < mincs[op]:
            mincs[op] = cost
        if 'CreateModel' in str(op) and cost > 10000:
            import pdb
            pdb.set_trace()

    # normalize disk and runcost to minc
    G1p, G2p = [], []
    for (r,o,s), g1, g2 in zip(trips, G1, G2):
        G1p.append(g1 / max(G1dict[o]) * mincs[o])
        G2p.append(g2 / max(G2dict[o]) * mincs[o])
    c = map(sum, zip(c, G1p, G2p))
    cp = list(c)
    d = dict([(t, cost) for cost, t in zip(c, trips)])
    c = matrix(c)
    
    nlog.debug("Constraints: %f\t%f" , maxdisk, maxoverhead)
    for (r, op, s), pqcost in zip(trips, G1p):
#        if 'CumO' not in str(op): continue
        nlog.debug('%s\t%s\t%.15f\t%f\t%f\t%.15f', op, str(s).ljust(25),
                   pqcost,
#.........这里部分代码省略.........
开发者ID:sirrice,项目名称:pstore,代码行数:103,代码来源:nlp.py

示例4: gen_nlp

# 需要导入模块: from stats import Stats [as 别名]
# 或者: from stats.Stats import instance [as 别名]
 def gen_nlp(self, maxdisk=500, maxoverhead=0.5):
     strategies = run_nlp(Stats.instance(), self, maxdisk, maxoverhead)
     for op, strats in strategies.items():
         wlog.info("%s\t%s", op, ', '.join(map(str, strats)))
     wlog.info("\n")
     return strategies
开发者ID:sirrice,项目名称:pstore,代码行数:8,代码来源:op.py


注:本文中的stats.Stats.instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。