Hello,
I would like to maximize efficiency of string processing in my C#
application that works with Skype API. Actually, these "strings" are made of
"chars" that are all 8-bit values except 0 (1-255).
1. Is there a way to make C# use 8-bit char so that the memory usage is
reduced?
2. Should StringBuilder be used in place of string while they are being
processed? I haven't done it so far since StringBuilder doesn't have Trim,
StartWith, Substring, & Split functions that I use extensively. Would it be
more efficient to use StringBuilder and convert to string for these missing
functions?
3. Is there an encoding that can efficiently convert byte value (0-255) into
non-zero byte values (1-255)?
4. Are there any other things I should be looking for to raise efficiency?
Regards,
Vinay Agarwal 4 3562 Actually, these "strings" are made of "chars" that are all 8-bit values except 0 (1-255).
Just the fact that you put strings in quotes is a clear indication
that you're using the wrong data type.
1. Is there a way to make C# use 8-bit char so that the memory usage is reduced?
No, but why aren't you using a byte array instead of strring/char?
2. Should StringBuilder be used in place of string while they are being processed?
That's usually a good idea, yes.
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Vinay Agarwal wrote: Hello,
I would like to maximize efficiency of string processing in my C# application that works with Skype API. Actually, these "strings" are made of "chars" that are all 8-bit values except 0 (1-255).
Are you actually having any efficiency problems? Does the profiler
indicate so?
1. Is there a way to make C# use 8-bit char so that the memory usage is reduced?
How large are those strings? you may be able to "save" half the mem by
using a byte[] representation, but really, are you having memory problems?
2. Should StringBuilder be used in place of string while they are being processed? I haven't done it so far since StringBuilder doesn't have Trim, StartWith, Substring, & Split functions that I use extensively. Would it be more efficient to use StringBuilder and convert to string for these missing functions?
"While they are being processed"?
StringBuilder *builds* strings, and is good if you concatenate many
strings together, but if you are calling StartWith, Substring & Split,
you are not concatenating.
3. Is there an encoding that can efficiently convert byte value (0-255) into non-zero byte values (1-255)?
You are not suggesting to complicate your memory representation by
compressing from the domain 1-255 into 0-255, are you?
--
Helge Jensen
mailto:he****** ****@slog.dk
sip:he********* *@slog.dk
-=> Sebastian cover-music: http://ungdomshus.nu <=-
Vinay Agarwal <Vi**********@d iscussions.micr osoft.com> wrote: I would like to maximize efficiency of string processing in my C# application that works with Skype API. Actually, these "strings" are made of "chars" that are all 8-bit values except 0 (1-255).
Hmm... are they *actually* text characters, or are you really just
representing binary data?
1. Is there a way to make C# use 8-bit char so that the memory usage is reduced?
Well, you could use a byte array instead - but then you can't treat it
like a string. You could write your own class which had string-like
facilities, but if you needed to display it (or the like) you'd need to
convert it to a string.
2. Should StringBuilder be used in place of string while they are being processed? I haven't done it so far since StringBuilder doesn't have Trim, StartWith, Substring, & Split functions that I use extensively. Would it be more efficient to use StringBuilder and convert to string for these missing functions?
StringBuilder can help if you don't need the intermediate values, but
it's no use otherwise.
3. Is there an encoding that can efficiently convert byte value (0-255) into non-zero byte values (1-255)?
Well, you'll need some sort of escaping, effectively - for instance,
making 255 255 represent 255, but 255 1 represent 0, leaving all other
values as they are. It's not going to be terribly pleasant either way.
4. Are there any other things I should be looking for to raise efficiency?
Well, firstly, do you know that you've got a problem? It's not worth
wasting time and potentially making your code less elegant if you don't
have a performance problem in real life.
Secondly, if you're actually dealing with binary data, don't try to
treat it like a string - you'll end up with really nasty bugs that way.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Sorry for the late response, I was interrupted by other tasks. From your
feedbad, I understand that I need to look into optimization as a whole and
not focus on strings only. I just started looking into profiler tools--not
sure which is the best, but I will start out with dotTrace. Thanks for your
help.
Regards,
Vinay Agarwal This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jacek Generowicz |
last post by:
I have a multiple disptacher which, conceptually, looks something like
this:
class Multimethod:
def __init__(self):
self.methods = {}
|
by: ArShAm |
last post by:
Hi there
Please help me to optimize this code for speed
I added /O2 to compiler settings
I added /Oe to compiler settings for accepting register type request , but
it seems that is not allowed and if I remove register type for "l" , time of
generating codes doesn't change
the original code makes some files , but I removed that section to make it
simple for you to read
please help me to optimize it for faster running
|
by: Aidan |
last post by:
The setup: a Sax parser in a servlet and a Java client (same machine) which
uploads an XML document containing CDATA elements which hold base 64
encoded binary files. The servlet then SAX parses the client's data. If I
comment out the parser call I can see that the transmition time of large
data files is very low.
My understanding is that a SAX parser should transmit the content of a CDATA
string downstream without signiificant...
|
by: prcpani |
last post by:
I have a program that will read as follows
#define MS(x) memset(x.arr,'\0',sizeof(x.arr))
void memset_var()
{
int cnt =0;
|
by: Brian |
last post by:
In particular, this question goes out to the Microsoft C++ development
team. Back in June, Ronald Laeremans posted the following message. Has
the optimizing compiler been included with the standard edition of VC++
yet? Don't think that we've forgotten about it....
Thank,
Brian
From: Ronald Laeremans (ronaldl@online.microsoft.com)
| |
by: Michael Powe |
last post by:
Hello,
I have written a small app to parse web log files and extract certain
lines to another file. There is also functionality to count all the
items that are being filtered out.
I wrote this in c# instead of in perl because the log files are 3-4GB
and I want faster processing than perl would typically provide. And,
I'm learning c#.
|
by: Diffident |
last post by:
Hello All,
I need some help on optimizing a piece of code. Currently this is how we
retrieve our Oracle's connection string for executing all the queries in our
application.
public string GetOracleClientConnectionString()
{
string strConnectionString =
System.Configuration.ConfigurationSettings.AppSettings;
|
by: Nick Gilbert |
last post by:
Hi,
I have to send an array of prices for a list of products over XML.
Currently my XML data looks like this:
<ArrayOfProd>
<Prod Code="productcode001">
<Prices>
<P F="2005-01-01" T="2005-09-09" Q="10" V="27.50" />
|
by: roswara |
last post by:
Dear all,
Does anyone know the maximum amount of columns of a table in a database? Currently, I am using SQL Server 2005. Is it normal to have 50 columns in a table? I wonder about the optimization of query processing. Should I split them into several tables to optimize query processing time? But if I split them, will it guarantee that my query processing time will be faster? As we know, if we split it into several tables, there must be...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |