[Gambas-user] What's faster: RegExp or String function

Jussi Lahtinen jussi.lahtinen at ...626...
Wed Nov 30 18:53:35 CET 2011


Why don't you run benchmarks to find out?


Dim ff As Float
Dim ii As Integer

ff = Timer

For ii = 1 To SomeNumber

 FunctionToTest()

Next

Print "Time to run: " & CStr(Timer - ff)


Choose value for "SomeNumber" so that run time is significant enough to
give reasonably reliable measurement,
in other words run time should be 10 seconds or more.

Jussi




2011/11/30 Phạm Quang Dương <soleilpqd at ...626...>

> Hi all,
>
> I want to remove all substring marked with '<>'. I have 2 functions:
>
> Dim rEx As New Regexp
> rEx.Compile("<.*>")
> rEx.Exec(s)
> While rEx.Offset >= 0
>    s = Replace(s, rEx.Text, "")
>    rEx.Exec(s)
> Wend
>
> And
>
> i=Instr(s,"<")
> while i > 0
>    j=InStr(s,">",  i)
>    cut out from s the substring from i to j
>    i=Instr(s,"<")
> wend
>
> Which one should I choose?
> Thank you :)
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list