本文整理匯總了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)