nodejs:
var SphinxClient = require('sphinxapi'),
docs = ['this is my test text to be highlighted','this is another test text to be highlighted'];
words = 'test text';
index = 'test';
opts = {'before_match':'', 'after_match':'', 'chunk_separator':' ... ', 'limit':400, 'around':15};
var cl = new SphinxClient();
cl.SetServer('localhost', 9312);
for (i=0;i<1000;i++) {
cl.BuildExcerpts (docs, index, words, opts, function(error, results) {
console.log(results)
})
}
real 0m31.281s
python:
from sphinxapi import *
import sys
docs = ['this is my test text to be highlighted','this is another test text to be highlighted']
words = 'test text'
index = 'test'
opts = {'before_match':'', 'after_match':'', 'chunk_separator':' ... ', 'limit':400, 'around':15}
i = 0
cl = SphinxClient()
cl.Open()
while i < 1000:
res = cl.BuildExcerpts(docs, index, words, opts)
print res
i = i + 1
print i
cl.Close()
real 0m0.854s
user 0m0.071s
sys 0m0.021s
Why ?