Submitter | Simon Heimberg |
---|---|
Date | Feb. 7, 2013, 5:59 a.m. |
Message ID | <752845f990b6544b4c22.1360216791@lapsi.heimberg.home> |
Download | mbox | patch |
Permalink | /patch/824/ |
State | Superseded |
Commit | 15711d9d8b2caebf97d36f54417cd237f1154d93 |
Headers | show |
Comments
On Wed, Feb 6, 2013 at 9:59 PM, Simon Heimberg <simohe@besonet.ch> wrote: > tests: quickly check if the glob line already matches the output > Does this have any practical impact?
Am 08.02.2013 11:52, schrieb Bryan O'Sullivan: > On Wed, Feb 6, 2013 at 9:59 PM, Simon Heimberg <simohe@besonet.ch > <mailto:simohe@besonet.ch>> wrote: > > tests: quickly check if the glob line already matches the output > > > Does this have any practical impact? Well, this one not because there is a bug. The comparison should be "el + '\n' == l". And with the corrected line not a big impact. We theoretically win 0.07 milliseconds when running all tests. I will resend the fixed patch with the next one for showing a real use. Greetings, Simon ================================ Calculations: 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.) ========================================== python script for testing the run time of globalmatch, to run in the tests directory ========================================== p = None # for pattern, make globally available rt = __import__("run-tests") gm = rt.globmatch def t(n = 50000): """returns the mean time for matching, in us (micro seconds) returns the mean time for running the matching function, once for direct match, once for failed """ r = [] setup = 'from __main__ import gm, c, p' global p for p in [c.rstrip(), c.rstrip().replace('/', '?', 2)]: r.append(timeit.Timer('gm(p, c)', setup).timeit(number=n) / n * 1000000) return r c = "an/example/string/to/check\n" if __name__ == "__main__": print t() ========================================== shell line for couning glob lines with no * and ? ========================================== grep -c "^[^\*\?]*(glob)" *.t | awk -F ":" 'BEGIN {S=0} {printf("%03d %s\n", $2, $1); S=S+$2} END {print " =>", S}'
Patch
diff -r 0fe362f445f0 -r 752845f990b6 tests/run-tests.py --- a/tests/run-tests.py Die Nov 06 01:05:43 2012 +0100 +++ b/tests/run-tests.py Mon Okt 15 23:02:19 2012 +0200 @@ -548,6 +548,8 @@ def globmatch(el, l): # The only supported special characters are * and ? plus / which also # matches \ on windows. Escaping of these caracters is supported. + if el == l: + return True i, n = 0, len(el) res = '' while i < n: