Search

Silverlight 4 code using IndexOf, StartsWith, Endswith default overloads very slow for XP browsers by FridayFish

Closed
as External Help for as External

3
0
Sign in
to vote
Type: Bug
ID: 615069
Opened: 10/19/2010 2:39:43 PM
Access Restriction: Public
1
Workaround(s)
2
User(s) can reproduce this bug
If a silverlight 4 application uses IndexOf("abc"), StartsWith("abc") or EndsWith("abc") on a string which contains characters above char(127) without specifying the StringComparison.Ordinal overload, or specifing a "culture" StringComparison overload, then when a user on a XP PC browses to the silverlight application the response time is extremely slow. Users browsing from Vista or Windows 7 are not affected. Multivalued databases (i.e. RainingData D3) use char(254) as "attribute mark", char(253) as a "value mark" and char(252) as a "subvalue mark". Hence strings containing chars past char(127) are very common.
Web Browers running on XP hang taking all the CPU cycles.
StringComparision options which cause many seconds or minutes delay are:
not specified, CurrentCulture, CurrentCultureIgnoreCase, InvariantCulture, InvariantCultureIgnoreCase. Delay only occurs if string object contains characters above char(127) - i.e char(128) to char(255).
Details (expand)

Visual Studio/Silverlight/Tooling version

Silverlight 4

What category (if any) best represents this feedback?

Performance

Steps to reproduce

1)Create Silverlight 4.0.50917.0 application. (2) Create "s" as 20,000 character string with 20% of characters that are char(254). (3) Browse to application using Windows XP SP3 PC, or run VS2010 on a XP SP3 PC. (4) Measure elapsed time it takes to perform:
dim x as integer = s.IndexOf("abc")
dim y as integer = s.StartsWith("abc")
dim z as integer = s.EndsWith("abc")



Product Language

English

Operating System

Windows XP

Operating System Language

English (US)

Actual results

Each string action in form s.IndexOf("abc") elapsed time is 21 seconds.
If code is changed to s.IndexOf("abc",StringComparison.Ordinal), elapsed time is 0 seconds.
If code is changed to s.IndexOf("abc",StringComparison.CurrentCultureIgnoreCase), elapsed time is 22 seconds.

Output of testcase, with all options set, 20,000 char string, 20% equal Char(128). "After" time is elapsed time in hh:mm:ss.mmm

before std indexof with stringcomparison.ordinal 00:00:00
after std indexof with stringcomparison.ordinal 00:00:00

before std indexof with stringcomparison.OrdinalIgnoreCase 00:00:00
after std indexof with stringcomparison.OrdinalIgnoreCase 00:00:00

before std indexof with stringcomparison.CurrentCulture 00:00:00
after std indexof with stringcomparison.CurrentCulture 00:00:21.2232314

before std indexof with stringcomparison.CurrentCultureIgnoreCase 00:00:00
after std indexof with stringcomparison.CurrentCultureIgnoreCase 00:00:21.9421332

before std indexof with stringcomparison.InvariantCulture 00:00:00
after std indexof with stringcomparison.InvariantCulture 00:00:21.2388597

before std indexof with stringcomparison.InvariantCultureIgnoreCase 00:00:00
after std indexof with stringcomparison.InvariantCultureIgnoreCase 00:00:22.2078143

before std indexof 00:00:00
after std indexof 00:00:21.2701163

Expected results

Elapsed time of 0 seconds for all.
File Attachments
File Name Submitted By Submitted On File Size  
IndexOf Test Case.txt 10/19/2010 2 KB
Sign in to post a comment.
Posted by Microsoft on 4/7/2011 at 11:53 AM
Hello FridayFish,
Thank you for the post. We will investigate this Windows XP performance scenario in a future release of Silverlight.
Posted by Microsoft on 10/19/2010 at 3:23 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Igor Macedo1 on 12/7/2010 at 5:48 AM
https://connect.microsoft.com/VisualStudio/feedback/details/629358/performance-problem-string-indexof-and-string-startswith