Skip to content

Instantly share code, notes, and snippets.

@MOON-CLJ
Last active December 29, 2015 12:49
Show Gist options
  • Save MOON-CLJ/7673534 to your computer and use it in GitHub Desktop.
Save MOON-CLJ/7673534 to your computer and use it in GitHub Desktop.
本地database直接访问 有cache和没cache(100万,大于10s的差异才被保留)
- 141990135 function calls in 4517.825 seconds
+ 141990135 function calls in 305.731 seconds
- 15732127 35.384 0.000 41.229 0.000 __init__.py:6549(__init__)
+ 15732127 27.876 0.000 32.483 0.000 __init__.py:6549(__init__)
class TermListItem(object):
def __init__(self, iter, term):
self._iter = iter
self.term = term
self._wdf = None
self._termfreq = None
if iter._has_wdf == TermIter.EAGER:
self._wdf = iter._iter.get_wdf()
if iter._has_termfreq == TermIter.EAGER:
self._termfreq = iter._iter.get_termfreq()
# Support for sequence API
sequence = ['term', 'wdf', 'termfreq', 'positer']
if iter._has_wdf == TermIter.INVALID:
sequence[1] = 0
if iter._has_termfreq == TermIter.INVALID:
sequence[2] = 0
if iter._has_positions == TermIter.INVALID:
sequence[3] = PositionIter()
- 17117501 63.263 0.000 126.670 0.000 __init__.py:6688(next)
+ 17117501 47.963 0.000 96.793 0.000 __init__.py:6688(next)
class TermIter(object):
def next(self):
if not self._moved:
self._iter.next()
self._moved = True
if self._iter == self._end:
self._lastterm = None
raise StopIteration
else:
self._lastterm = self._iter.get_term()
self._moved = False
if self._return_strings:
return self._lastterm
return TermListItem(self, self._lastterm)
- 1385374 10.329 0.000 2919.839 0.002 __init__.py:6883(_document_gen_termlist_iter)
+ 1385374 5.034 0.000 53.815 0.000 __init__.py:6883(_document_gen_termlist_iter)
def _document_gen_termlist_iter(self):
return TermIter(self.termlist_begin(), self.termlist_end(),
has_termfreq=TermIter.LAZY,
has_wdf=TermIter.EAGER,
has_positions=TermIter.LAZY)
Document.__iter__ = _document_gen_termlist_iter
Document.termlist = _document_gen_termlist_iter
- 1385374 2.180 0.000 1325.704 0.001 xapian_backend.py:281(_get_document_data)
+ 1385374 1.357 0.000 43.220 0.000 xapian_backend.py:281(_get_document_data)
def _extract_item(self, doc, fields):
r = msgpack.unpackb(self._get_document_data(self.database, doc))
if fields is not None:
item = {}
for field in fields:
if field == 'terms':
item['terms'] = {term.term[5:]: term.wdf for term in doc.termlist() if term.term.startswith('XTEXT')}
else:
item[field] = r.get(field)
else:
item = r
return item
class Document(object):
def get_data(self): 9
return _xapian.Document_get_data(self)
--- 3.txt 2013-11-21 15:12:57.000000000 +0800
+++ 4.txt 2013-11-21 15:12:57.000000000 +0800
@@ -1,4 +1,4 @@
- 141990135 function calls in 4517.825 seconds
+ 141990135 function calls in 305.731 seconds
Ordered by: standard name
@@ -18,7 +18,7 @@
1 0.000 0.000 0.000 0.000 __init__.py:1897(ValuePostingSource)
1 0.000 0.000 0.000 0.000 __init__.py:1928(ValueWeightPostingSource)
1 0.000 0.000 0.000 0.000 __init__.py:1968(DecreasingValueWeightPostingSource)
- 1 0.000 0.000 0.001 0.001 __init__.py:2(<module>)
+ 1 0.001 0.001 0.001 0.001 __init__.py:2(<module>)
1 0.000 0.000 0.000 0.000 __init__.py:2002(ValueMapPostingSource)
1 0.000 0.000 0.000 0.000 __init__.py:201(LogicError)
1 0.000 0.000 0.000 0.000 __init__.py:2072(FixedWeightPostingSource)
@@ -33,7 +33,7 @@
1 0.000 0.000 0.000 0.000 __init__.py:2732(ExpandDecider)
1 0.000 0.000 0.000 0.000 __init__.py:2753(Enquire)
1 0.000 0.000 0.000 0.000 __init__.py:2770(__init__)
- 1 0.000 0.000 0.004 0.004 __init__.py:28(swig_import_helper)
+ 1 0.000 0.000 0.005 0.005 __init__.py:28(swig_import_helper)
1 0.000 0.000 0.000 0.000 __init__.py:280(InvalidArgumentError)
1 0.000 0.000 0.000 0.000 __init__.py:312(InvalidOperationError)
1 0.000 0.000 0.000 0.000 __init__.py:3164(Registry)
@@ -50,7 +50,7 @@
1 0.000 0.000 0.000 0.000 __init__.py:406(DatabaseCorruptError)
1 0.000 0.000 0.000 0.000 __init__.py:4282(WritableDatabase)
1 0.000 0.000 0.000 0.000 __init__.py:437(DatabaseCreateError)
- 1 0.001 0.001 0.003 0.003 __init__.py:44(<module>)
+ 1 0.002 0.002 0.004 0.004 __init__.py:44(<module>)
1 0.000 0.000 0.000 0.000 __init__.py:468(DatabaseLockError)
1 0.000 0.000 0.001 0.001 __init__.py:4768(open_stub)
1 0.000 0.000 0.000 0.000 __init__.py:4951(Query)
@@ -78,24 +78,24 @@
1 0.000 0.000 0.000 0.000 __init__.py:6084(ValueSetMatchDecider)
1 0.000 0.000 0.000 0.000 __init__.py:6142(Compactor)
1 0.000 0.000 0.000 0.000 __init__.py:6340(MSetItem)
- 1385374 7.680 0.000 12.989 0.000 __init__.py:6377(__init__)
- 1385374 4.386 0.000 13.626 0.000 __init__.py:6388(_get_document)
+ 1385374 6.071 0.000 10.045 0.000 __init__.py:6377(__init__)
+ 1385374 3.434 0.000 10.567 0.000 __init__.py:6388(_get_document)
1 0.000 0.000 0.000 0.000 __init__.py:639(FeatureUnavailableError)
1 0.000 0.000 0.000 0.000 __init__.py:6395(MSetIter)
1 0.000 0.000 0.000 0.000 __init__.py:6403(__init__)
- 1385375 4.504 0.000 17.931 0.000 __init__.py:6412(next)
+ 1385375 3.701 0.000 14.111 0.000 __init__.py:6412(next)
1 0.000 0.000 0.000 0.000 __init__.py:6433(_mset_gen_iter)
1 0.000 0.000 0.000 0.000 __init__.py:6467(ESetItem)
1 0.000 0.000 0.000 0.000 __init__.py:6482(ESetIter)
1 0.000 0.000 0.000 0.000 __init__.py:6533(TermListItem)
- 15732127 35.384 0.000 41.229 0.000 __init__.py:6549(__init__)
- 11576005 4.694 0.000 4.694 0.000 __init__.py:6569(_get_wdf)
+ 15732127 27.876 0.000 32.483 0.000 __init__.py:6549(__init__)
+ 11576005 3.367 0.000 3.367 0.000 __init__.py:6569(_get_wdf)
1 0.000 0.000 0.000 0.000 __init__.py:6651(TermIter)
- 1385374 2.982 0.000 2.982 0.000 __init__.py:6665(__init__)
- 1385374 0.293 0.000 0.293 0.000 __init__.py:6684(__iter__)
- 17117501 63.263 0.000 126.670 0.000 __init__.py:6688(next)
+ 1385374 1.733 0.000 1.733 0.000 __init__.py:6665(__init__)
+ 1385374 0.184 0.000 0.184 0.000 __init__.py:6684(__iter__)
+ 17117501 47.963 0.000 96.793 0.000 __init__.py:6688(next)
1 0.000 0.000 0.000 0.000 __init__.py:674(InternalError)
- 1385374 10.329 0.000 2919.839 0.002 __init__.py:6883(_document_gen_termlist_iter)
+ 1385374 5.034 0.000 53.815 0.000 __init__.py:6883(_document_gen_termlist_iter)
1 0.000 0.000 0.000 0.000 __init__.py:6944(wrapper)
1 0.000 0.000 0.000 0.000 __init__.py:6965(wrapper)
6 0.000 0.000 0.000 0.000 __init__.py:6990(_query_init)
@@ -174,7 +174,7 @@
1 0.000 0.000 0.000 0.000 query_base.py:246(build_query_tree)
1 0.000 0.000 0.000 0.000 query_base.py:261(grammar_tree)
1 0.000 0.000 0.000 0.000 query_base.py:301(parse_query)
- 1 0.003 0.003 0.011 0.011 query_base.py:4(<module>)
+ 1 0.004 0.004 0.012 0.012 query_base.py:4(<module>)
1 0.000 0.000 0.000 0.000 query_base.py:45(QueryCompilerVisitor)
1 0.000 0.000 0.000 0.000 query_base.py:50(__init__)
1 0.000 0.000 0.000 0.000 query_base.py:54(visit_combination)
@@ -204,7 +204,7 @@
2 0.000 0.000 0.000 0.000 sre_parse.py:90(__init__)
1 0.000 0.000 0.000 0.000 stat.py:24(S_IFMT)
1 0.000 0.000 0.000 0.000 stat.py:49(S_ISREG)
- 1 1.958 1.958 4517.825 4517.825 test_stub_file_open_tcp.py:3(<module>)
+ 1 1.492 1.492 305.731 305.731 test_stub_file_open_tcp.py:3(<module>)
1 0.000 0.000 0.001 0.001 threading.py:1(<module>)
1 0.000 0.000 0.000 0.000 threading.py:103(_RLock)
2 0.000 0.000 0.000 0.000 threading.py:180(Condition)
@@ -234,7 +234,7 @@
1 0.000 0.000 0.000 0.000 util.py:306(ForkAwareThreadLock)
1 0.000 0.000 0.000 0.000 util.py:313(ForkAwareLocal)
1 0.001 0.001 0.002 0.002 util.py:35(<module>)
- 1 0.002 0.002 0.010 0.010 utils.py:4(<module>)
+ 1 0.003 0.003 0.012 0.012 utils.py:4(<module>)
1 0.000 0.000 0.000 0.000 utils.py:59(load_one_words)
1 0.000 0.000 0.000 0.000 utils.py:68(timeit)
1 0.000 0.000 0.000 0.000 utils.py:78(SimpleMapReduce)
@@ -242,19 +242,19 @@
1 0.000 0.000 0.000 0.000 warnings.py:45(filterwarnings)
1 0.000 0.000 0.000 0.000 weakref.py:47(__init__)
3 0.000 0.000 0.000 0.000 xapian_backend.py:118(fields_not_empty)
- 1 0.000 0.000 29.337 29.337 xapian_backend.py:119(_)
+ 1 0.000 0.000 29.189 29.189 xapian_backend.py:119(_)
1 0.000 0.000 0.000 0.000 xapian_backend.py:127(XapianSearch)
1 0.000 0.000 0.002 0.002 xapian_backend.py:128(__init__)
1 0.000 0.000 0.000 0.000 xapian_backend.py:18(Schema)
- 1 0.000 0.000 29.337 29.337 xapian_backend.py:196(search)
- 1385375 7.179 0.000 4486.504 0.003 xapian_backend.py:221(result_generator)
- 1385374 14.250 0.000 4447.769 0.003 xapian_backend.py:227(_extract_item)
- 1385374 39.236 0.000 179.277 0.000 xapian_backend.py:233(<dictcomp>)
- 1 0.000 0.000 28.836 28.836 xapian_backend.py:262(_get_enquire_mset)
- 1385374 2.180 0.000 1325.704 0.001 xapian_backend.py:281(_get_document_data)
+ 1 0.000 0.000 29.189 29.189 xapian_backend.py:196(search)
+ 1385375 5.465 0.000 275.021 0.000 xapian_backend.py:221(result_generator)
+ 1385374 8.651 0.000 244.878 0.000 xapian_backend.py:227(_extract_item)
+ 1385374 27.065 0.000 133.848 0.000 xapian_backend.py:233(<dictcomp>)
+ 1 0.000 0.000 28.685 28.685 xapian_backend.py:262(_get_enquire_mset)
+ 1385374 1.357 0.000 43.220 0.000 xapian_backend.py:281(_get_document_data)
1 0.000 0.000 0.001 0.001 xapian_backend.py:350(_stub_database)
1 0.000 0.000 0.000 0.000 xapian_backend.py:380(InvalidIndexError)
- 1 0.002 0.002 0.023 0.023 xapian_backend.py:4(<module>)
+ 1 0.002 0.002 0.027 0.027 xapian_backend.py:4(<module>)
2 0.000 0.000 0.000 0.000 {_sre.compile}
12 0.000 0.000 0.000 0.000 {_sre.getlower}
1 0.000 0.000 0.000 0.000 {_xapian.AssertionError_swigregister}
@@ -274,13 +274,13 @@
1 0.000 0.000 0.000 0.000 {_xapian.DateValueRangeProcessor_swigregister}
1 0.000 0.000 0.000 0.000 {_xapian.DecreasingValueWeightPostingSource_swigregister}
1 0.000 0.000 0.000 0.000 {_xapian.DocNotFoundError_swigregister}
- 1385374 1323.524 0.001 1323.524 0.001 {_xapian.Document_get_data}
+ 1385374 41.863 0.000 41.863 0.000 {_xapian.Document_get_data}
1 0.000 0.000 0.000 0.000 {_xapian.Document_swigregister}
- 1385374 2904.628 0.002 2904.628 0.002 {_xapian.Document_termlist_begin}
- 1385374 1.900 0.000 1.900 0.000 {_xapian.Document_termlist_end}
+ 1385374 46.196 0.000 46.196 0.000 {_xapian.Document_termlist_begin}
+ 1385374 0.851 0.000 0.851 0.000 {_xapian.Document_termlist_end}
1 0.000 0.000 0.000 0.000 {_xapian.ESetIterator_swigregister}
1 0.000 0.000 0.000 0.000 {_xapian.ESet_swigregister}
- 1 28.836 28.836 28.836 28.836 {_xapian.Enquire_get_mset}
+ 1 28.685 28.685 28.685 28.685 {_xapian.Enquire_get_mset}
1 0.000 0.000 0.000 0.000 {_xapian.Enquire_set_collapse_key}
1 0.000 0.000 0.000 0.000 {_xapian.Enquire_set_docid_order}
1 0.000 0.000 0.000 0.000 {_xapian.Enquire_set_weighting_scheme}
@@ -295,20 +295,20 @@
1 0.000 0.000 0.000 0.000 {_xapian.InvalidOperationError_swigregister}
1 0.000 0.000 0.000 0.000 {_xapian.KeyMaker_swigregister}
1 0.000 0.000 0.000 0.000 {_xapian.LogicError_swigregister}
- 1385374 0.587 0.000 0.587 0.000 {_xapian.MSetIterator_get_collapse_count}
- 1385374 1.398 0.000 1.398 0.000 {_xapian.MSetIterator_get_collapse_key}
- 1385374 0.769 0.000 0.769 0.000 {_xapian.MSetIterator_get_docid}
- 1385374 5.639 0.000 5.639 0.000 {_xapian.MSetIterator_get_document}
- 1385374 0.805 0.000 0.805 0.000 {_xapian.MSetIterator_get_percent}
- 1385374 0.439 0.000 0.439 0.000 {_xapian.MSetIterator_get_rank}
- 1385374 0.556 0.000 0.556 0.000 {_xapian.MSetIterator_get_weight}
- 1385374 0.438 0.000 0.438 0.000 {_xapian.MSetIterator_next}
+ 1385374 0.396 0.000 0.396 0.000 {_xapian.MSetIterator_get_collapse_count}
+ 1385374 1.038 0.000 1.038 0.000 {_xapian.MSetIterator_get_collapse_key}
+ 1385374 0.575 0.000 0.575 0.000 {_xapian.MSetIterator_get_docid}
+ 1385374 4.597 0.000 4.597 0.000 {_xapian.MSetIterator_get_document}
+ 1385374 0.624 0.000 0.624 0.000 {_xapian.MSetIterator_get_percent}
+ 1385374 0.343 0.000 0.343 0.000 {_xapian.MSetIterator_get_rank}
+ 1385374 0.440 0.000 0.440 0.000 {_xapian.MSetIterator_get_weight}
+ 1385374 0.365 0.000 0.365 0.000 {_xapian.MSetIterator_next}
1 0.000 0.000 0.000 0.000 {_xapian.MSetIterator_swigregister}
- 1385374 3.600 0.000 3.600 0.000 {_xapian.MSet__get_hit_internal}
+ 1385374 2.536 0.000 2.536 0.000 {_xapian.MSet__get_hit_internal}
1 0.000 0.000 0.000 0.000 {_xapian.MSet_begin}
1 0.000 0.000 0.000 0.000 {_xapian.MSet_end}
- 1 0.500 0.500 0.500 0.500 {_xapian.MSet_fetch}
- 1385374 0.756 0.000 0.756 0.000 {_xapian.MSet_get_firstitem}
+ 1 0.504 0.504 0.504 0.504 {_xapian.MSet_fetch}
+ 1385374 0.559 0.000 0.559 0.000 {_xapian.MSet_get_firstitem}
1 0.000 0.000 0.000 0.000 {_xapian.MSet_size}
1 0.000 0.000 0.000 0.000 {_xapian.MSet_swigregister}
1 0.000 0.000 0.000 0.000 {_xapian.MatchDecider_swigregister}
@@ -342,9 +342,9 @@
1 0.000 0.000 0.000 0.000 {_xapian.StringValueRangeProcessor_swigregister}
1 0.000 0.000 0.000 0.000 {_xapian.SwigPyIterator_swigregister}
1 0.000 0.000 0.000 0.000 {_xapian.TermGenerator_swigregister}
- 15732127 9.535 0.000 9.535 0.000 {_xapian.TermIterator_get_term}
- 15732127 5.845 0.000 5.845 0.000 {_xapian.TermIterator_get_wdf}
- 15732127 12.643 0.000 12.643 0.000 {_xapian.TermIterator_next}
+ 15732127 6.831 0.000 6.831 0.000 {_xapian.TermIterator_get_term}
+ 15732127 4.607 0.000 4.607 0.000 {_xapian.TermIterator_get_wdf}
+ 15732127 9.516 0.000 9.516 0.000 {_xapian.TermIterator_next}
1 0.000 0.000 0.000 0.000 {_xapian.TermIterator_swigregister}
1 0.000 0.000 0.000 0.000 {_xapian.TradWeight_swigregister}
1 0.000 0.000 0.000 0.000 {_xapian.UnimplementedError_swigregister}
@@ -377,7 +377,7 @@
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
294 0.000 0.000 0.000 0.000 {method 'endswith' of 'str' objects}
7 0.000 0.000 0.000 0.000 {method 'extend' of 'list' objects}
- 1385381 0.711 0.000 0.711 0.000 {method 'get' of 'dict' objects}
+ 1385381 0.337 0.000 0.337 0.000 {method 'get' of 'dict' objects}
1 0.000 0.000 0.000 0.000 {method 'insert' of 'list' objects}
3 0.000 0.000 0.000 0.000 {method 'items' of 'dict' objects}
2 0.000 0.000 0.000 0.000 {method 'join' of 'str' objects}
@@ -390,13 +390,13 @@
2 0.000 0.000 0.000 0.000 {method 'rstrip' of 'str' objects}
5 0.000 0.000 0.000 0.000 {method 'setter' of 'property' objects}
2 0.000 0.000 0.000 0.000 {method 'split' of 'str' objects}
- 15732374 8.677 0.000 8.677 0.000 {method 'startswith' of 'str' objects}
+ 15732374 6.624 0.000 6.624 0.000 {method 'startswith' of 'str' objects}
60 0.000 0.000 0.000 0.000 {method 'strip' of 'str' objects}
2 0.000 0.000 0.000 0.000 {method 'timetuple' of 'datetime.datetime' objects}
42 0.000 0.000 0.000 0.000 {method 'update' of 'dict' objects}
12 0.000 0.000 0.000 0.000 {method 'upper' of 'str' objects}
4 0.000 0.000 0.000 0.000 {min}
- 1385374 7.696 0.000 7.696 0.000 {msgpack._unpacker.unpackb}
+ 1385374 4.822 0.000 4.822 0.000 {msgpack._unpacker.unpackb}
1 0.000 0.000 0.000 0.000 {open}
21 0.000 0.000 0.000 0.000 {ord}
2 0.000 0.000 0.000 0.000 {posix.getcwd}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment