<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Am 08.02.2013 11:52, schrieb Bryan
O'Sullivan:<br>
</div>
<blockquote
cite="mid:CACw0niKeA0rYSdx373S-1FDhaKeatuYRnazQoHuTLWxyrO8V1Q@mail.gmail.com"
type="cite">On Wed, Feb 6, 2013 at 9:59 PM, Simon Heimberg <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:simohe@besonet.ch" target="_blank">simohe@besonet.ch</a>></span>
wrote:<br>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div id=":1gi">tests: quickly check if the glob line already
matches the output<br>
</div>
</blockquote>
</div>
<br>
Does this have any practical impact?
</blockquote>
Well, this one not because there is a bug. The comparison should be
"el + '\n' == l".<br>
And with the corrected line not a big impact. We theoretically win
0.07 milliseconds when running all tests.<br>
I will resend the fixed patch with the next one for showing a real
use.<br>
<br>
Greetings,<br>
Simon<br>
<br>
================================<br>
Calculations:<br>
Comparing an equal line goes down from 178 to 1.6 micro seconds. In
the entire test suite, there are 482 lines with a glob matching only
"/". This is a maximum speed-up of 0.07 microseconds. (The slowdown
from 153 to 169 micro seconds for a normal match on 861 lines is
considered.)<br>
<br>
==========================================<br>
python script for testing the run time of globalmatch, to run in the
tests directory<br>
==========================================<br>
p = None # for pattern, make globally available<br>
<br>
rt = __import__("run-tests")<br>
gm = rt.globmatch<br>
<br>
def t(n = 50000):<br>
"""returns the mean time for matching, in us (micro seconds)<br>
<br>
returns the mean time for running the matching function,<br>
once for direct match, once for failed<br>
"""<br>
r = []<br>
setup = 'from __main__ import gm, c, p'<br>
global p<br>
for p in [c.rstrip(), c.rstrip().replace('/', '?', 2)]:<br>
r.append(timeit.Timer('gm(p, c)', setup).timeit(number=n) /
n * 1000000)<br>
return r<br>
<br>
c = "an/example/string/to/check\n"<br>
<br>
if __name__ == "__main__":<br>
print t()<br>
<br>
==========================================<br>
shell line for couning glob lines with no * and ?<br>
==========================================<br>
grep -c "^[^\*\?]*(glob)" *.t | awk -F ":" 'BEGIN {S=0}<br>
{printf("%03d %s\n", $2, $1); S=S+$2}<br>
END {print " =>", S}'<br>
</body>
</html>