in reply to You learn something every day
is around thirty times faster
Actually this dependent on the size of @patterns. When I benchmark them against each other i get more like a 100% speedup. Precalculating a hash of the patterns and then doing a hash lookup is infinitely faster.
Testing 100 Benchmark: running bigrex, forex, hash, each for at least 1 CPU second +s... bigrex: 1 wallclock secs ( 1.09 usr + 0.02 sys = 1.11 CPU) @ 19 +103.70/s (n=21186) forex: 1 wallclock secs ( 1.11 usr + 0.00 sys = 1.11 CPU) @ 44 +43.24/s (n=4932) hash: 2 wallclock secs ( 1.14 usr + 0.00 sys = 1.14 CPU) @ 16 +32288.34/s (n=1862441) Rate forex bigrex hash forex 4443/s -- -77% -100% bigrex 19104/s 330% -- -99% hash 1632288/s 36636% 8444% -- Testing 10000 Benchmark: running bigrex, forex, hash, each for at least 1 CPU second +s... bigrex: 1 wallclock secs ( 1.06 usr + 0.00 sys = 1.06 CPU) @ 83 +.80/s (n=89) forex: 2 wallclock secs ( 1.03 usr + 0.00 sys = 1.03 CPU) @ 42 +.68/s (n=44) hash: 1 wallclock secs ( 1.05 usr + 0.00 sys = 1.05 CPU) @ 13 +97043.89/s (n=1464102) Rate forex bigrex hash forex 42.7/s -- -49% -100% bigrex 83.8/s 96% -- -100% hash 1397044/s 3273428% 1666934% -- Testing 100000 Benchmark: running bigrex, forex, hash, each for at least 1 CPU second +s... bigrex: 1 wallclock secs ( 1.08 usr + 0.00 sys = 1.08 CPU) @ 7 +.42/s (n=8) forex: 2 wallclock secs ( 1.17 usr + 0.00 sys = 1.17 CPU) @ 4 +.27/s (n=5) hash: 2 wallclock secs ( 1.03 usr + 0.00 sys = 1.03 CPU) @ 12 +19285.16/s (n=1257083) Rate forex bigrex hash forex 4.27/s -- -43% -100% bigrex 7.42/s 74% -- -100% hash 1219285/s 28579944% 16429768% --
So id say you learned something new today too. :-) (use a hash...)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: You learn something every day
by Jasper (Chaplain) on Aug 04, 2003 at 22:02 UTC | |
by demerphq (Chancellor) on Aug 05, 2003 at 07:17 UTC |