[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

string.StartsWith() duration is proportional to string length!

AAA

8/10/2008 12:03:00 PM

string.StartsWith() duration is proportional to string length!!!!!

Has anybody come across this, besides me ?
I posted all info here, as a bug to microsoft:

http://connect.microsoft.com/wf/feedback/ViewFeedback.aspx?Feedbac...


I'm just puzzled:
How can this be ? Are they copying all chars to a char-arr, before testing ?
How stupid is that ?

M.


10 Answers

CB@PrayForMe.com

8/3/2008 12:01:00 PM

0


"Jeff McCann" <NoSpam@NoThanks.org> wrote in message
news:qt4lk.3225$IB6.2027@bignews8.bellsouth.net...
> CB wrote:
>> "Jeff McCann" <NoSpam@NoThanks.org> wrote in message
>> news:0z3lk.3203$IB6.1978@bignews8.bellsouth.net...
>>> Poetic Justice wrote:
>>>> Jeff McCann wrote:
>>>>> CB wrote:
>>>>>> "Jeff McCann" <NoSpam@NoThanks.org> wrote in message
>>>>>> news:XY1lk.3156$IB6.680@bignews8.bellsouth.net...
>>>>>>> CB wrote:
>>>>>>>> <Nicklas@Click.com> wrote in message
>>>>>>>> news:er199455rbd9vq4trj9u8tgg0590njor20@4ax.com...
>>>>>>>>> On Sat, 02 Aug 2008 04:32:27 -0700, Gunner Asch
>>>>>>>>> <gunner@NOSPAMlightspeed.net> wrote:
>>>>>>>>>
>>>>>>>>>> On Fri, 1 Aug 2008 19:59:31 -0400, "Larry Hewitt"
>>>>>>>>>> <larryhewi@comporium.net> wrote:
>>>>>>>>>>
>>>>>>>>>>> You;re a selfish, racist pig who ares less for the future of
>>>>>>>>>>> hte country
>>>>>>>>>>> than for his his warped philosphy.
>>>>>>>>>> Coming from you...the irony is exquisite...absoulutely
>>>>>>>>>> exquisite....
>>>>>>>>>> "[L]iberals are afraid to state what they truly believe in,
>>>>>>>>> Well, that's just an outright lie.....
>>>>>>>>>
>>>>>>>>> We believe in:
>>>>>>>>>
>>>>>>>>> Aiding the homeless, hungry, children, elderly, the
>>>>>>>>> working class, educating the public, providing "safety
>>>>>>>>> net" compensation to the retired, women, children.
>>>>>>>>>
>>>>>>>>> We believe in regulation of Wealth and power to the
>>>>>>>>> benefit of the Majority of society--not just the
>>>>>>>>> enhancement of the wealth and power class
>>>>>>>>>
>>>>>>>>> We believe that business and corporations must shoulder
>>>>>>>>> their responsibilities and provide adequate safety and
>>>>>>>>> compensation, along with compliance with those
>>>>>>>>> provisions of law that protect the greater mass of
>>>>>>>>> working class---including fair labor standards, fair
>>>>>>>>> wages, equal employment opportunites
>>>>>>>>>
>>>>>>>>> It would a LOT shorter list if a conservative could
>>>>>>>>> list ANYTHING designed to help the bottom 3/4ths of
>>>>>>>>> American society they ever propositioned or supported
>>>>>>>>> over the last--say---80 years.
>>>>>>> More like the bottom 99.5% of American society
>>>>>>>
>>>>>>>> To late, teaching to be morally responsibil for ones self and
>>>>>>>> family has become a hate crime
>>>>>>> Since Social Security has largely eliminated personal responsibility
>>>>>>> for all of one's family other than oneself, it is far easier for
>>>>>>> Rightards to tout their wholly fictional belief in self-reliance and
>>>>>>> personal responsibility.
>>>>>> Anyone who relies on SS for retirement has planed their life very
>>>>>> poorly.
>>>> Why then, is it here at all??????
>>> Life is mostly composed of whatever happens to you while you were busy
>>> making other plans. Few people "plan" to become widowed at age 28 with
>>> three small children to raise, or to become seriously disabled at age
>>> 35, or to find that their employers have welshed on their retirement
>>> plan obligations at age 60.
>>
>> What responsibility do I have for them, other than paying 25-28% federal
>> tax?
>
> That's for you to decide. If you feel no sense of moral responsibility to
> your family or community, that's your issue, not mine.

I do for my family

>
> Jeff


CB@PrayForMe.com

8/3/2008 12:23:00 PM

0


"Poetic Justice" <@http://Poetic-Justice.Talk-n-D... wrote in message
news:Xo5lk.3076$vX2.1549@bignews6.bellsouth.net...
> CB wrote:
>> <Nicklas@Click.com> wrote in message
>> news:er199455rbd9vq4trj9u8tgg0590njor20@4ax.com...
>>> On Sat, 02 Aug 2008 04:32:27 -0700, Gunner Asch
>>> <gunner@NOSPAMlightspeed.net> wrote:
>>>
>>>> On Fri, 1 Aug 2008 19:59:31 -0400, "Larry Hewitt"
>>>> <larryhewi@comporium.net> wrote:
>>>>
>>>>> You;re a selfish, racist pig who ares less for the future of hte
>>>>> country
>>>>> than for his his warped philosphy.
>>>>
>>>> Coming from you...the irony is exquisite...absoulutely exquisite....
>>>> "[L]iberals are afraid to state what they truly believe in,
>>> Well, that's just an outright lie.....
>>>
>>> We believe in:
>>>
>>> Aiding the homeless, hungry, children, elderly, the
>>> working class, educating the public, providing "safety
>>> net" compensation to the retired, women, children.
>
> The devil is in the details:
>
> How do "you" help these?
> How do "you" educate?
> "You" provide what safety net?
> The retired provide their own, YOU stole it from them.
> Women are equal to men and need no special "compensation"
>
>
> Children have Parents to care for them.... In the few cases that don't
> have parents, they have distant family and in the few cases that have
> neither the private charity's can fill the gap.
>
>
>>>
>>> We believe in regulation of Wealth and power to the
>>> benefit of the Majority of society--not just the
>>> enhancement of the wealth and power class
>>>
>
> Because you were divinely empowered to dictate who needs what? And because
> of your poor decisions about ENERGY and FOOD, when the food shortage grows
> to a point that your neighbors are starving you will REGULATE who gets
> food and who starves to death... right? Naturally you'll stand up and
> claim your place as one of the "divine" who regulated the wealth until
> that point and volunteer yourself and your family to starve in place of
> the others.... right?
>
>
> If you take the Accolades you need to take the crap too.
>
>>> We believe that business and corporations must shoulder
>>> their responsibilities and provide adequate safety and
>>> compensation, along with compliance with those
>>> provisions of law that protect the greater mass of
>>> working class---including fair labor standards, fair
>>> wages, equal employment opportunites
>>>
>
> What is a fair wage? Some employees do nothing, others do all you require
> and more. Give me a number, what is an hour of your life worth, I'll buy
> one and have you crawl for an hour so I can be entertained.
>
> How much is a theater ticket worth, what would you place as fair to pay
> for that.... Maybe I should pay more to laugh at you for an hour if you
> call it theater?
>
>
>>> It would a LOT shorter list if a conservative could
>>> list ANYTHING designed to help the bottom 3/4ths of
>>> American society they ever propositioned or supported
>>> over the last--say---80 years.
>>
>
> Financial education. Learn that today is not your last and no one will
> feed you tomorrow. Then you will learn to help yourselves or starve.

"If your ship doesn't come in, swim out to it." -Andy Tant
Lib/Dim version: "If your ship doesn't present its self to you, sink it and
blame duh mayhn"

"Learn all you can, but learn to do something, or your learning will be
useless and your vision will depart." -Booker T. Washington

Butt in Gary's case...

After all, "It's Hard Out Here for a Pimp"
http://www.hustlean... #Foe


>
>> To late, teaching to be morally responsibil for ones self and family has
>> become a hate crime
>>
>> All else trickles down from there
>>
>>> THen we could all have a good laugh.
>
> Yes, the funny thing is that you say you want to help, the problem is....
> you want to steal from others and then give that away to help. Somehow
> that loses it's Pious standing. Why don't you get a second job and use
> the money to help the poor. Or start a business and charge extra for your
> service or product, then use that to help the "homeless, hungry,
> children, elderly, the working class, educating the public, providing
> "safety net" compensation to the retired, women, children."

It would mean for Gary to have personal interest in what he moralizes other
to do

>
> Instead you choose to become a thief.
>
>
> Why do Liberals think using *stolen money* to *pay someone else* to help
> these people is worthy of accolades?

Here comes the part where Libs have created the safety net...and deny that
welfare has enslaved the poor to generational poverty.

>
> Liberals aren't much when it comes to *personal growth* are they? They
> want to just give someone else's money to pay somebody else to deal with
> the problem, rather than doing the work or earning the money.

While the form of treachery varies slightly from case to case, liberals
always manage to take the position that most undermines American security.
--Ann Coulter

By espousing Marxism, the philosophy of taking from the productive and
gibbing it to the elite, as if it'll 'trickle-down' to where it's needed the
most.

>
> How does that work for you, does voting to steal others money and voting
> to pay someone else to help the poor give you a clean conscience.
>
>
> Laugh now,,,, but why do you create a PAC, and then fund it to steal
> others money, why didn't you just use the money to allow you to help the
> poor and give your money and time directly to the needy?

That would mean for Gary to get up and move around


CB@PrayForMe.com

8/3/2008 12:26:00 PM

0


"Gunner Asch" <gunner@NOSPAMlightspeed.net> wrote in message
news:05pa945hio1lhjgngsqdaev6a28nhva5mj@4ax.com...
> On Sat, 2 Aug 2008 23:13:02 -0400, "Larry Hewitt"
> <larryhewi@comporium.net> wrote:
>
>>>>
>>>>This fool is defending CB, a racist pig wh throws the n-word around and
>>>>is
>>>>against mixed marriages, stole from the government and brags about it,
>>>>claims to be a christian while spreading racist hate, and is wrong on
>>>>the
>>>>facts on every important issue
>>>
>>>
>>> Oh...like Jessee Jackson?
>>>
>>
>>Ah, anotehr racist who runs from the truth.
>>
>>Larry
>
>
> Racist? Hummm..you may be right. After all the Right Reverand Jackson
> did use the term Nigger recently when talking about Obama
>
> Gunner

It's ok for Afro-Americans to use 'nigger', not white folk. Don't ax why, it
just be

After all, "It's Hard Out Here for a Pimp"
http://www.hustlean... #Foe


Gunner Asch

8/4/2008 2:20:00 AM

0

On Sun, 3 Aug 2008 17:32:04 -0500, "Jorge W. Arbusto, Prezidentchul
Candydate" <cleanin_the_stables@fakeranch.tx> wrote:

>
>If you take up residence in one of the "red" states, you'll learn that
>rightards believe that personal responsibility is for everyone but
>themselves. Hence the higher divorce rates and out of wedlock birthrates
>in the red states.


Oh...like California?


The hottest places in hell are reserved for those
who in times of great moral crisis maintain their neutrality",
John F. Kennedy.

RichTravsky

8/6/2008 3:01:00 AM

0

CB wrote:
>
> "Larry Hewitt" <larryhewi@comporium.net> wrote in message
> news:duydnWrSC7v5sw_V4p2dnAA@comporium.net...
> >
> > "Gunner" <gunner@NOSPAM.lightspeed.net> wrote in message
> > news:ut63945sr6msis51g41dmpc260dsspsj37@4ax.com...
> >> On Sat, 26 Jul 2008 21:37:54 -0600, Rich Travsky
> >> <traRvEsky@hotmMOVEail.com> wrote:
> >>
> >>>>
> >>>> America produces the greatest output too...for now. If Dim Lib Commies
> >>>> have
> >>>> their way America will decline from Energy constriction.
> >>>
> >>>If dumb cons have their way there'd be no alternative sources.
> >>
> >> Sure Trotsky..sure
> >>
> >> One assumes that its the Liberal side of Big Oil that is investing all
> >> those petro dollars in alternative energy resources, eh wot?
> >
> > Repugs have shot down a bill this week to extend tax credits for
> > alternative energy.
> > A number of projects , including one in McCain;s home state, are
> > threatening to shut down and build in Europe if the credits are not
> > extended.
>
> The devil be in the details, what earmarks or other pet projects did Pelosi
> or Reid stick (to the American people) in the bill?

None.


http://www.startribune.com/politics/national/congress/26123044.html?location_refer...
...
For the fourth time this summer, Republicans stopped the Senate from taking up
wide-ranging legislation that extends tax breaks for teachers, businesses and
parents and provides tax credits to an array of renewable energy entrepreneurs.
...


> > Repugs don;t care.
> >
> > McCain ran from the vote.
> >
> > On the record as supporting the credits, but at hte center of the offshore
> > drilling brouhaha, McCain is avoiding the vote so he won;t piss off one of
> > his constituencies.

Jeroen Mostert

8/10/2008 1:35:00 PM

0

AAA wrote:
> string.StartsWith() duration is proportional to string length!!!!!
>
> Has anybody come across this, besides me ?
> I posted all info here, as a bug to microsoft:
>
> http://connect.microsoft.com/wf/feedback/ViewFeedback.aspx?Feedbac...
>
>
> I'm just puzzled:
> How can this be ? Are they copying all chars to a char-arr, before testing ?
> How stupid is that ?
>
Here's the output on my machine. The results are consistent over multiple runs.

Warmup = False






4408 1000 False
1416 10000 False
1424 100000 True
1376 1000000 False
1168 10000000 False
1160 100000000 False

What version of the framework are you using? I'm using .NET 3.5, so that's
2.0 SP1 for the runtime.

What culture are you running it in? Try .StartsWith(...,
StringComparison.Ordinal) to do a culture-insensitive comparison.

--
J.

Göran Andersson

8/10/2008 2:20:00 PM

0

Jeroen Mostert wrote:
> AAA wrote:
>> string.StartsWith() duration is proportional to string length!!!!!
>>
>> Has anybody come across this, besides me ?
>> I posted all info here, as a bug to microsoft:
>>
>> http://connect.microsoft.com/wf/feedback/ViewFeedback.aspx?Feedbac...
>>
>>
>>
>> I'm just puzzled:
>> How can this be ? Are they copying all chars to a char-arr, before
>> testing ?
>> How stupid is that ?
>>
> Here's the output on my machine. The results are consistent over
> multiple runs.
>
> Warmup = False
>
>
>
>
>
>
> 4408 1000 False
> 1416 10000 False
> 1424 100000 True
> 1376 1000000 False
> 1168 10000000 False
> 1160 100000000 False
>
> What version of the framework are you using? I'm using .NET 3.5, so
> that's 2.0 SP1 for the runtime.
>
> What culture are you running it in? Try .StartsWith(...,
> StringComparison.Ordinal) to do a culture-insensitive comparison.
>

I can't see any difference due to string length either. Here's the
result that I get:

41 1000 False
24 10000 False
24 100000 True
25 1000000 False
23 10000000 False
22 100000000 False


I changed the test a bit to rule out some inconsistencies in the
measuring. It does more than a single call for each string and measures
time in seconds instead of ticks (as that obviously varies greatly from
system to system):

....
double[] times = new double[levels];
....
sw.Start();
for (int j = 0; j < 1000000; j++) {
results[i] = (strs[i].StartsWith("ccc"));
}
sw.Stop();
// store duration in the times array
times[i] = (double)sw.ElapsedTicks / (double)Stopwatch.Frequency;
....
output = string.Format("{0:N6}\t\t{1}\t\t{2}", times[i], strs[i].Length,
results[i]);
....

Then I get this result:

0,159523 1000 False
0,159885 10000 False
0,159741 100000 True
0,167306 1000000 False
0,157622 10000000 False
0,153183 100000000 False


I also tried adding StringComparison.Ordinal, with the only difference
that it's about eight times faster:

0,021114 1000 False
0,021875 10000 False
0,024070 100000 True
0,021946 1000000 False
0,019754 10000000 False
0,020303 100000000 False

--
Göran Andersson
_____
http://www...

AAA

8/13/2008 11:14:00 AM

0

Sorry - I just double-checked:
Still happens on my machine!

3339 1000 False
32472 10000 False
313191 100000 True
3114747 1000000 False
31068720 10000000 False
312031152 100000000 False



My culture is "English (United States)".
System.Environment.Version returns "2.0.50727.1433"


It is an XP machine:

OS Name Microsoft Windows XP Professional
Version 5.1.2600 Service Pack 2 Build 2600
OS Manufacturer Microsoft Corporation
System Name XXXXXXXX
System Manufacturer LENOVO
System Model 8811VSD
System Type X86-based PC
Processor x86 Family 6 Model 15 Stepping 6 GenuineIntel ~2393 Mhz
Processor x86 Family 6 Model 15 Stepping 6 GenuineIntel ~2394 Mhz
BIOS Version/Date LENOVO 2JKT36AUS, 5/6/2007
SMBIOS Version 2.4
Windows Directory C:\WINDOWS
System Directory C:\WINDOWS\system32
Boot Device \Device\HarddiskVolume1
Locale United States
Hardware Abstraction Layer Version = "5.1.2600.2180
(xpsp_sp2_rtm.040803-2158)"
User Name XXXX\XXXX
Time Zone Jerusalem Daylight Time
Total Physical Memory 2,048.00 MB
Available Physical Memory 996.95 MB
Total Virtual Memory 2.00 GB
Available Virtual Memory 1.96 GB
Page File Space 3.84 GB
Page File C:\pagefile.sys


M.



"Göran Andersson" <guffa@guffa.com> wrote in message
news:e5f$hQv%23IHA.4780@TK2MSFTNGP05.phx.gbl...
> Jeroen Mostert wrote:
>> AAA wrote:
>>> string.StartsWith() duration is proportional to string length!!!!!
>>>
>>> Has anybody come across this, besides me ?
>>> I posted all info here, as a bug to microsoft:
>>>
>>> http://connect.microsoft.com/wf/feedback/ViewFeedback.aspx?Feedbac...
>>>
>>>
>>> I'm just puzzled:
>>> How can this be ? Are they copying all chars to a char-arr, before
>>> testing ?
>>> How stupid is that ?
>>>
>> Here's the output on my machine. The results are consistent over multiple
>> runs.
>>
>> Warmup = False
>>
>>
>>
>>
>>
>>
>> 4408 1000 False
>> 1416 10000 False
>> 1424 100000 True
>> 1376 1000000 False
>> 1168 10000000 False
>> 1160 100000000 False
>>
>> What version of the framework are you using? I'm using .NET 3.5, so
>> that's 2.0 SP1 for the runtime.
>>
>> What culture are you running it in? Try .StartsWith(...,
>> StringComparison.Ordinal) to do a culture-insensitive comparison.
>>
>
> I can't see any difference due to string length either. Here's the result
> that I get:
>
> 41 1000 False
> 24 10000 False
> 24 100000 True
> 25 1000000 False
> 23 10000000 False
> 22 100000000 False
>
>
> I changed the test a bit to rule out some inconsistencies in the
> measuring. It does more than a single call for each string and measures
> time in seconds instead of ticks (as that obviously varies greatly from
> system to system):
>
> ...
> double[] times = new double[levels];
> ...
> sw.Start();
> for (int j = 0; j < 1000000; j++) {
> results[i] = (strs[i].StartsWith("ccc"));
> }
> sw.Stop();
> // store duration in the times array
> times[i] = (double)sw.ElapsedTicks / (double)Stopwatch.Frequency;
> ...
> output = string.Format("{0:N6}\t\t{1}\t\t{2}", times[i], strs[i].Length,
> results[i]);
> ...
>
> Then I get this result:
>
> 0,159523 1000 False
> 0,159885 10000 False
> 0,159741 100000 True
> 0,167306 1000000 False
> 0,157622 10000000 False
> 0,153183 100000000 False
>
>
> I also tried adding StringComparison.Ordinal, with the only difference
> that it's about eight times faster:
>
> 0,021114 1000 False
> 0,021875 10000 False
> 0,024070 100000 True
> 0,021946 1000000 False
> 0,019754 10000000 False
> 0,020303 100000000 False
>
> --
> Göran Andersson
> _____
> http://www...


AAA

8/13/2008 11:19:00 AM

0

Ordinal works great:

3078 1000 False
747 10000 False
2313 100000 True
1062 1000000 False
1080 10000000 False
684 100000000 False


This is a good work-around for me.
Still - I wish it was fixed, because most developer will forget to add the
ordinal.


M.




"Göran Andersson" <guffa@guffa.com> wrote in message
news:e5f$hQv%23IHA.4780@TK2MSFTNGP05.phx.gbl...
> Jeroen Mostert wrote:
>> AAA wrote:
>>> string.StartsWith() duration is proportional to string length!!!!!
>>>
>>> Has anybody come across this, besides me ?
>>> I posted all info here, as a bug to microsoft:
>>>
>>> http://connect.microsoft.com/wf/feedback/ViewFeedback.aspx?Feedbac...
>>>
>>>
>>> I'm just puzzled:
>>> How can this be ? Are they copying all chars to a char-arr, before
>>> testing ?
>>> How stupid is that ?
>>>
>> Here's the output on my machine. The results are consistent over multiple
>> runs.
>>
>> Warmup = False
>>
>>
>>
>>
>>
>>
>> 4408 1000 False
>> 1416 10000 False
>> 1424 100000 True
>> 1376 1000000 False
>> 1168 10000000 False
>> 1160 100000000 False
>>
>> What version of the framework are you using? I'm using .NET 3.5, so
>> that's 2.0 SP1 for the runtime.
>>
>> What culture are you running it in? Try .StartsWith(...,
>> StringComparison.Ordinal) to do a culture-insensitive comparison.
>>
>
> I can't see any difference due to string length either. Here's the result
> that I get:
>
> 41 1000 False
> 24 10000 False
> 24 100000 True
> 25 1000000 False
> 23 10000000 False
> 22 100000000 False
>
>
> I changed the test a bit to rule out some inconsistencies in the
> measuring. It does more than a single call for each string and measures
> time in seconds instead of ticks (as that obviously varies greatly from
> system to system):
>
> ...
> double[] times = new double[levels];
> ...
> sw.Start();
> for (int j = 0; j < 1000000; j++) {
> results[i] = (strs[i].StartsWith("ccc"));
> }
> sw.Stop();
> // store duration in the times array
> times[i] = (double)sw.ElapsedTicks / (double)Stopwatch.Frequency;
> ...
> output = string.Format("{0:N6}\t\t{1}\t\t{2}", times[i], strs[i].Length,
> results[i]);
> ...
>
> Then I get this result:
>
> 0,159523 1000 False
> 0,159885 10000 False
> 0,159741 100000 True
> 0,167306 1000000 False
> 0,157622 10000000 False
> 0,153183 100000000 False
>
>
> I also tried adding StringComparison.Ordinal, with the only difference
> that it's about eight times faster:
>
> 0,021114 1000 False
> 0,021875 10000 False
> 0,024070 100000 True
> 0,021946 1000000 False
> 0,019754 10000000 False
> 0,020303 100000000 False
>
> --
> Göran Andersson
> _____
> http://www...


AAA

8/13/2008 12:06:00 PM

0

I don't know how I posted the bug to the wrong place at Microsoft:
I'm not using the "WF" thing, so it was just a simple mistake.

Anyway, I re-posted here:

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?Feedbac...


FYI
M.


"Göran Andersson" <guffa@guffa.com> wrote in message
news:e5f$hQv%23IHA.4780@TK2MSFTNGP05.phx.gbl...
> Jeroen Mostert wrote:
>> AAA wrote:
>>> string.StartsWith() duration is proportional to string length!!!!!
>>>
>>> Has anybody come across this, besides me ?
>>> I posted all info here, as a bug to microsoft:
>>>
>>> http://connect.microsoft.com/wf/feedback/ViewFeedback.aspx?Feedbac...
>>>
>>>
>>> I'm just puzzled:
>>> How can this be ? Are they copying all chars to a char-arr, before
>>> testing ?
>>> How stupid is that ?
>>>
>> Here's the output on my machine. The results are consistent over multiple
>> runs.
>>
>> Warmup = False
>>
>>
>>
>>
>>
>>
>> 4408 1000 False
>> 1416 10000 False
>> 1424 100000 True
>> 1376 1000000 False
>> 1168 10000000 False
>> 1160 100000000 False
>>
>> What version of the framework are you using? I'm using .NET 3.5, so
>> that's 2.0 SP1 for the runtime.
>>
>> What culture are you running it in? Try .StartsWith(...,
>> StringComparison.Ordinal) to do a culture-insensitive comparison.
>>
>
> I can't see any difference due to string length either. Here's the result
> that I get:
>
> 41 1000 False
> 24 10000 False
> 24 100000 True
> 25 1000000 False
> 23 10000000 False
> 22 100000000 False
>
>
> I changed the test a bit to rule out some inconsistencies in the
> measuring. It does more than a single call for each string and measures
> time in seconds instead of ticks (as that obviously varies greatly from
> system to system):
>
> ...
> double[] times = new double[levels];
> ...
> sw.Start();
> for (int j = 0; j < 1000000; j++) {
> results[i] = (strs[i].StartsWith("ccc"));
> }
> sw.Stop();
> // store duration in the times array
> times[i] = (double)sw.ElapsedTicks / (double)Stopwatch.Frequency;
> ...
> output = string.Format("{0:N6}\t\t{1}\t\t{2}", times[i], strs[i].Length,
> results[i]);
> ...
>
> Then I get this result:
>
> 0,159523 1000 False
> 0,159885 10000 False
> 0,159741 100000 True
> 0,167306 1000000 False
> 0,157622 10000000 False
> 0,153183 100000000 False
>
>
> I also tried adding StringComparison.Ordinal, with the only difference
> that it's about eight times faster:
>
> 0,021114 1000 False
> 0,021875 10000 False
> 0,024070 100000 True
> 0,021946 1000000 False
> 0,019754 10000000 False
> 0,020303 100000000 False
>
> --
> Göran Andersson
> _____
> http://www...