From: Martin on 2 Feb 2010 10:30 2 added thanks Martin "Willie Moore" <williem(a)wmconsulting.com> wrote in message news:hk98fq$277$1(a)speranza.aioe.org... Martin, If you want more speed, use at2 or at3. They are the strongly typed versions of at. Regards, Willie __________ Information from ESET NOD32 Antivirus, version of virus signature database 4827 (20100202) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com
From: Johan Nel on 2 Feb 2010 10:49 Hi Martin, Thanks for that, mind sharing the code you used to test? Regards, Johan Martin wrote: > I found InStr slower than At() > > Very odd > > "Johan Nel" <johan.nel(a)xsinet.co.za> wrote in message > news:91a73506-8dd4-4ddc-ba74-08b449e22cd6(a)z26g2000yqm.googlegroups.com... > Martin, > > In principle from slowest to quickest: > 1. "abc" $ sMyString > 2. At("abc", sMyString) > 0 > 3. Rat("abc", sMyString > 0 > 4. InStr("abc", sMyString) > > So in short, InStr() is the fastest. > > HTH, > > Johan Nel > Pretoria, South Africa. > > On Feb 2, 1:40 pm, "Martin" <s...(a)spam.spam> wrote: >> To save having to run tests what is the quickest way of finding a string >> in >> a string? >> >> Thanks >> >> Martin > >
From: Martin on 2 Feb 2010 10:52 Formatting ruined by OE METHOD MyTests CLASS ClearDown LOCAL nLoop AS DWORD, n1 AS FLOAT, n2 AS FLOAT, n3 AS FLOAT, ; n4 AS FLOAT, n5 AS FLOAT, lTest AS LOGIC, ; aTest as array, aSearch as array, csearch as string, nloop2 as dword aTest := {'ABC ',; 'DCE ',; 'DCF ',; 'FCE '} cSearch := 'ABC |DCB |DCS |FCE |' aSearch := {'ABC ','DCB ','DCS ','FCE '} n1 := SECONDS() FOR nLoop := 1 TO 100000 FOR nLoop2 := 1 TO 4 lTest := InStr(aTest[nLoop2],cSearch) NEXT NEXT n2 := SECONDS() FOR nLoop := 1 TO 100000 FOR nLoop2 := 1 TO 4 lTest := AT(aTest[nLoop2],cSearch) > 0 NEXT NEXT n3 := SECONDS() FOR nLoop := 1 TO 100000 FOR nLoop2 := 1 TO 4 lTest := aTest[nLoop2] $ cSearch NEXT NEXT n4 := SECONDS() FOR nLoop := 1 TO 100000 FOR nLoop2 := 1 TO 4 lTest := ASCAN(aSearch,aTest[nLoop2]) > 0 NEXT NEXT n5 := SECONDS() Hit_Key(STR(n5-n4,10,4)+crlf+; STR(n4-n3,10,4)+crlf+; STR(n3-n2,10,4)+crlf+; STR(n2-n1,10,4)) RETURN NIL "Johan Nel" <johan.nel(a)xsinet.co.za> wrote in message news:hk9hi0$h38$1(a)news.eternal-september.org... > Hi Martin, > > Thanks for that, mind sharing the code you used to test? > > Regards, > > Johan > > Martin wrote: >> I found InStr slower than At() >> >> Very odd >> >> "Johan Nel" <johan.nel(a)xsinet.co.za> wrote in message >> news:91a73506-8dd4-4ddc-ba74-08b449e22cd6(a)z26g2000yqm.googlegroups.com... >> Martin, >> >> In principle from slowest to quickest: >> 1. "abc" $ sMyString >> 2. At("abc", sMyString) > 0 >> 3. Rat("abc", sMyString > 0 >> 4. InStr("abc", sMyString) >> >> So in short, InStr() is the fastest. >> >> HTH, >> >> Johan Nel >> Pretoria, South Africa. >> >> On Feb 2, 1:40 pm, "Martin" <s...(a)spam.spam> wrote: >>> To save having to run tests what is the quickest way of finding a string >>> in >>> a string? >>> >>> Thanks >>> >>> Martin >>
From: Johan Nel on 2 Feb 2010 11:09 Thanks Martin, Is weird that InStr() which is the Strong typed version of $ is slower. Might have to do with your USUAL array that it needs to do some checking if it is actually strings you passing in that causes the slowness. First thing I would look at is whether a: LOCAL c1 := 'ABC', c2 := 'DCE', c3 := 'DCF', c4 := 'FCE' AS STRING and removing of the array since USUAL needs to be converted to STRING etc have a significant impact. Also removal of the inner loop. n1 := SECONDS() FOR nLoop := 1 TO 100000 lTest := InStr(c1,cSearch) lTest := InStr(c2,cSearch) lTest := InStr(c3,cSearch) lTest := InStr(c4,cSearch) NEXT n2 := SECONDS() Regards, Johan. Martin wrote: > Formatting ruined by OE > > METHOD MyTests CLASS ClearDown > > LOCAL nLoop AS DWORD, n1 AS FLOAT, n2 AS FLOAT, n3 AS FLOAT, ; > n4 AS FLOAT, n5 AS FLOAT, lTest AS LOGIC, ; > aTest as array, aSearch as array, csearch as string, nloop2 as dword > > aTest := {'ABC ',; > 'DCE ',; > 'DCF ',; > 'FCE '} > > cSearch := 'ABC |DCB |DCS |FCE |' > > aSearch := {'ABC ','DCB ','DCS ','FCE '} > > n1 := SECONDS() > FOR nLoop := 1 TO 100000 > FOR nLoop2 := 1 TO 4 > lTest := InStr(aTest[nLoop2],cSearch) > NEXT > NEXT > n2 := SECONDS() > FOR nLoop := 1 TO 100000 > FOR nLoop2 := 1 TO 4 > lTest := AT(aTest[nLoop2],cSearch) > 0 > NEXT > NEXT > n3 := SECONDS() > FOR nLoop := 1 TO 100000 > FOR nLoop2 := 1 TO 4 > lTest := aTest[nLoop2] $ cSearch > NEXT > NEXT > n4 := SECONDS() > FOR nLoop := 1 TO 100000 > FOR nLoop2 := 1 TO 4 > lTest := ASCAN(aSearch,aTest[nLoop2]) > 0 > NEXT > NEXT > n5 := SECONDS() > > Hit_Key(STR(n5-n4,10,4)+crlf+; > STR(n4-n3,10,4)+crlf+; > STR(n3-n2,10,4)+crlf+; > STR(n2-n1,10,4)) > > > RETURN NIL > "Johan Nel" <johan.nel(a)xsinet.co.za> wrote in message > news:hk9hi0$h38$1(a)news.eternal-september.org... >> Hi Martin, >> >> Thanks for that, mind sharing the code you used to test? >> >> Regards, >> >> Johan >> >> Martin wrote: >>> I found InStr slower than At() >>> >>> Very odd >>> >>> "Johan Nel" <johan.nel(a)xsinet.co.za> wrote in message >>> news:91a73506-8dd4-4ddc-ba74-08b449e22cd6(a)z26g2000yqm.googlegroups.com... >>> Martin, >>> >>> In principle from slowest to quickest: >>> 1. "abc" $ sMyString >>> 2. At("abc", sMyString) > 0 >>> 3. Rat("abc", sMyString > 0 >>> 4. InStr("abc", sMyString) >>> >>> So in short, InStr() is the fastest. >>> >>> HTH, >>> >>> Johan Nel >>> Pretoria, South Africa. >>> >>> On Feb 2, 1:40 pm, "Martin" <s...(a)spam.spam> wrote: >>>> To save having to run tests what is the quickest way of finding a string >>>> in >>>> a string? >>>> >>>> Thanks >>>> >>>> Martin >
From: Geoff Schaller on 2 Feb 2010 16:22 Martin, But this is not a relevant test, is it! For starters, you need to start from where the string comes from, you need to state your compiler settings and so on. The next thing is that you are passing a discrete string as a local variable to the function calls so now you are introducing a performance killer that doesn't need to be there so again, your test is actually nonsense. What are you doing in the real app??? If you want fast then you really need to use something like MemAtSpecial() etc. Convert your search string to a byte array of chars and then do your search. Then you will be talking milliseconds instead of seconds. Geoff "Martin" <spam(a)spam.spam> wrote in message news:6TX9n.202449$gm2.115007(a)newsfe18.ams2: > Formatting ruined by OE > > METHOD MyTests CLASS ClearDown > > LOCAL nLoop AS DWORD, n1 AS FLOAT, n2 AS FLOAT, n3 AS FLOAT, ; > n4 AS FLOAT, n5 AS FLOAT, lTest AS LOGIC, ; > aTest as array, aSearch as array, csearch as string, nloop2 as dword > > aTest := {'ABC ',; > 'DCE ',; > 'DCF ',; > 'FCE '} >
First
|
Prev
|
Pages: 1 2 Prev: bBrowser - bArrayServer - SetFilter - Why does it happen? Next: Fastest way to delete records |