Re: Fast string operations
It is a very big app. And there are two main reasons for string usage:
1.) Much frequently-used data is cached in memory. This accounts for a
large, static memory block. However, due to legacy conditions, when we do
cache lookups from the legacy apps, they may pass in strings with whitespace
padding and such, so we have to trim before looking in the Hashtable.
Unfortunately, until we can completely get rid of the legacy apps, we have
to deal with the trimming.
2.) Since it's a CRM app, there are lots and lots and lots of strings.
Almost everything is string data... customer names, phone numbers,
addresses, customer interaction logs, phone logs, email logs, etc, etc, etc.
The vast majority (I'd say 70+%) of the data in the database (and thus data
that gets passed around through our app) are string data.
There isn't a lot of concatenation (well, maybe on the ASP side, but that
has no affect on .NET gen2 heap size) and we're cautious about using
StringBuilders and such.
-c
"KH" <KH@discussions .microsoft.com> wrote in message
news:C64637CA-28B1-46FF-9CA5-A4F7198779DB@mi crosoft.com...[color=blue]
> Array looping: The CLR has an optimization to remove bounds checking under
> certain conditions, mainly your basic for loop using Array.Length as the
> condition:
>
> for (int i=0; i < myarray.Length; ++i)
> {
> // presumably playing with the indexer or re-assigning the array
> variable
> // here would disable the optimization, but I don't really know.
> }
>
> Anyways I don't know what your app is but it must be mighty big to be so
> worried about string performance. It's usually over-use of strings that
> causes problems, like building strings by conditinally concatenating them,
> stuff like that that people don't realize causes a new instance of string
> to
> be created with EACH operation:
>
> string str1 = " ABC";
> string str2 = "DEF ";
> string str3 = (str1 + str2).ToLower() .Trim(); // 3 Strings created here
>
> If that's the real issue you might look into the StringBuilder class,
> which
> is mutable unlike String.
>
> - KH[/color]
It is a very big app. And there are two main reasons for string usage:
1.) Much frequently-used data is cached in memory. This accounts for a
large, static memory block. However, due to legacy conditions, when we do
cache lookups from the legacy apps, they may pass in strings with whitespace
padding and such, so we have to trim before looking in the Hashtable.
Unfortunately, until we can completely get rid of the legacy apps, we have
to deal with the trimming.
2.) Since it's a CRM app, there are lots and lots and lots of strings.
Almost everything is string data... customer names, phone numbers,
addresses, customer interaction logs, phone logs, email logs, etc, etc, etc.
The vast majority (I'd say 70+%) of the data in the database (and thus data
that gets passed around through our app) are string data.
There isn't a lot of concatenation (well, maybe on the ASP side, but that
has no affect on .NET gen2 heap size) and we're cautious about using
StringBuilders and such.
-c
"KH" <KH@discussions .microsoft.com> wrote in message
news:C64637CA-28B1-46FF-9CA5-A4F7198779DB@mi crosoft.com...[color=blue]
> Array looping: The CLR has an optimization to remove bounds checking under
> certain conditions, mainly your basic for loop using Array.Length as the
> condition:
>
> for (int i=0; i < myarray.Length; ++i)
> {
> // presumably playing with the indexer or re-assigning the array
> variable
> // here would disable the optimization, but I don't really know.
> }
>
> Anyways I don't know what your app is but it must be mighty big to be so
> worried about string performance. It's usually over-use of strings that
> causes problems, like building strings by conditinally concatenating them,
> stuff like that that people don't realize causes a new instance of string
> to
> be created with EACH operation:
>
> string str1 = " ABC";
> string str2 = "DEF ";
> string str3 = (str1 + str2).ToLower() .Trim(); // 3 Strings created here
>
> If that's the real issue you might look into the StringBuilder class,
> which
> is mutable unlike String.
>
> - KH[/color]
Comment