本文整理汇总了Python中intermine.webservice.Service.select方法的典型用法代码示例。如果您正苦于以下问题:Python Service.select方法的具体用法?Python Service.select怎么用?Python Service.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类intermine.webservice.Service
的用法示例。
在下文中一共展示了Service.select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Service
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import select [as 别名]
import sys
import os
sys.path.insert(0, os.getcwd())
from intermine.webservice import Service
import time
s = Service("localhost/intermine-test")
lazy = s.select("Department.*")
eager = s.select("Department.*", "Department.employees.*")
def do_work(q):
res = q.results()
age_sum = reduce(lambda x, y: x + reduce(lambda a, b: a + b.age, y.employees, 0), res, 0)
assert age_sum == 5798
if __name__ == "__main__":
tests = {"Lazy": lazy, "Eager": eager}
n = 10
print "Benchmarking %d iterations of " % n + ", ".join(tests.keys())
for label, q in tests.iteritems():
total = 0
for t in range(n):
a = time.time()
do_work(q)
b = time.time()
total += b - a
print "%s: total %s, avg: %s" % (label, total, total / n)