|
|
|
start date: Fri, 17 Aug 2007 02:00:01 -0700,
posted on: microsoft.public.dotnet.framework.compactframework
back
| Thread Index |
|
1
Viral
|
|
2
ctacke/ ctacke[at]opennetcf[dot]com
|
|
3
dbgrick
|
|
4
Simon Hart
|
StringBuilder Vs String
Hello Friends,
I know this question is not specific to .NET CF but as we are in the land of
less memory, I want to ask this question to all your techies. Its strange
thought in my mind.
we often hear that its adivsable to use StringBuilder when to many string
manipulations are there.
For example
Dim str1 as string
str1 &= "Viral"
str1 &= "Thakkar"
ok fine, but what about this case
---Dim str1 as string = "Viral" & "Thakkar"---
Is it still advisable to use stringbuilder, i mean in above case also it
will create two object.. bla bla bla?
thanks,
Viral
Date:Fri, 17 Aug 2007 02:00:01 -0700
Author:
|
Re: StringBuilder Vs String
For just 2 or 3 concatenations, a StringBuilder probably is slower than just
concatenating as you still have to create the object. When you get to say 4
or more, then the StringBuilder starts making sense.
--
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
"Viral" wrote in message
news:47B23140-31E6-4B3E-9840-E351F1F9864B@microsoft.com...
> Hello Friends,
>
> I know this question is not specific to .NET CF but as we are in the land
> of
> less memory, I want to ask this question to all your techies. Its strange
> thought in my mind.
>
> we often hear that its adivsable to use StringBuilder when to many string
> manipulations are there.
> For example
> Dim str1 as string
> str1 &= "Viral"
> str1 &= "Thakkar"
>
> ok fine, but what about this case
>
> ---Dim str1 as string = "Viral" & "Thakkar"---
> Is it still advisable to use stringbuilder, i mean in above case also it
> will create two object.. bla bla bla?
>
> thanks,
> Viral
>
>
>
>
Date:Fri, 17 Aug 2007 08:52:54 -0500
Author:
|
Re: StringBuilder Vs String
I was once at a contract that was very concerned with performance and we ran
a test using string concat and string builder. We found that for operations
of up to 10 concats it was more efficient to use string concats but more than
about 10 string builder was more efficient. We also found that when we were
memory constrained that preallocating the string buffer was always more
memory efficient.
Rick D.
Contractor
"<ctacke/>" wrote:
> For just 2 or 3 concatenations, a StringBuilder probably is slower than just
> concatenating as you still have to create the object. When you get to say 4
> or more, then the StringBuilder starts making sense.
>
>
> --
>
> Chris Tacke, Embedded MVP
> OpenNETCF Consulting
> Managed Code in an Embedded World
> www.OpenNETCF.com
>
>
> "Viral" wrote in message
> news:47B23140-31E6-4B3E-9840-E351F1F9864B@microsoft.com...
> > Hello Friends,
> >
> > I know this question is not specific to .NET CF but as we are in the land
> > of
> > less memory, I want to ask this question to all your techies. Its strange
> > thought in my mind.
> >
> > we often hear that its adivsable to use StringBuilder when to many string
> > manipulations are there.
> > For example
> > Dim str1 as string
> > str1 &= "Viral"
> > str1 &= "Thakkar"
> >
> > ok fine, but what about this case
> >
> > ---Dim str1 as string = "Viral" & "Thakkar"---
> > Is it still advisable to use stringbuilder, i mean in above case also it
> > will create two object.. bla bla bla?
> >
> > thanks,
> > Viral
> >
> >
> >
> >
>
>
>
Date:Fri, 17 Aug 2007 08:04:01 -0700
Author:
|
Re: StringBuilder Vs String
Did you find out why it was more efficient to use string concats over string
builder for less than 10 operations?
Preallocating memory has always been more efficient. Historically this is
the way it always was with languages such as COBOL and Fortran. It's only
newer languages (OO mainly) that had recently (20 yrs or so) has introduced
variable length types, I think Smalltalk 67 was the first? In the bad old
days you had to specify how much memory you needed and allocate it.
--
Simon Hart
http://simonrhart.blogspot.com
"dbgrick" wrote:
> I was once at a contract that was very concerned with performance and we ran
> a test using string concat and string builder. We found that for operations
> of up to 10 concats it was more efficient to use string concats but more than
> about 10 string builder was more efficient. We also found that when we were
> memory constrained that preallocating the string buffer was always more
> memory efficient.
>
> Rick D.
> Contractor
>
> "<ctacke/>" wrote:
>
> > For just 2 or 3 concatenations, a StringBuilder probably is slower than just
> > concatenating as you still have to create the object. When you get to say 4
> > or more, then the StringBuilder starts making sense.
> >
> >
> > --
> >
> > Chris Tacke, Embedded MVP
> > OpenNETCF Consulting
> > Managed Code in an Embedded World
> > www.OpenNETCF.com
> >
> >
> > "Viral" wrote in message
> > news:47B23140-31E6-4B3E-9840-E351F1F9864B@microsoft.com...
> > > Hello Friends,
> > >
> > > I know this question is not specific to .NET CF but as we are in the land
> > > of
> > > less memory, I want to ask this question to all your techies. Its strange
> > > thought in my mind.
> > >
> > > we often hear that its adivsable to use StringBuilder when to many string
> > > manipulations are there.
> > > For example
> > > Dim str1 as string
> > > str1 &= "Viral"
> > > str1 &= "Thakkar"
> > >
> > > ok fine, but what about this case
> > >
> > > ---Dim str1 as string = "Viral" & "Thakkar"---
> > > Is it still advisable to use stringbuilder, i mean in above case also it
> > > will create two object.. bla bla bla?
> > >
> > > thanks,
> > > Viral
> > >
> > >
> > >
> > >
> >
> >
> >
Date:Sat, 18 Aug 2007 12:42:00 -0700
Author:
|
|
|