Using C++/CLI but I would imagine C# is the same.
What is the fastest to do the following operations
1) Compare two Strings without case-sensitivity.
2) Take a group of objects with 4 string fields and tabulate them, so
each field is in a column, in a single String, one line per object
with \n separating them, calculating the minimum width required for
each column and them formatting the rows so all the fields in each
column line up.
So at the moment I'm
i) Looping over all the objects determining the minimum width of each
column.
ii) Creating a format string with something like String::Format( "{{0,-
{0}}}{{1,-{1}}}{{2,-{2}}}{{3}}\n", columnWidth1, columnWidth2,
columnWidth3);
iii) Then doing pLine += String::Format( pFmt, pLine->Type, pLine-
>Name, pLine->Value, pLine->Desc) +
"\n";
Anyway to make this faster?
TIA,
KK 3 1665 ke***********@g ooglemail.com wrote:
Using C++/CLI but I would imagine C# is the same.
What is the fastest to do the following operations
1) Compare two Strings without case-sensitivity.
2) Take a group of objects with 4 string fields and tabulate them, so
each field is in a column, in a single String, one line per object
with \n separating them, calculating the minimum width required for
each column and them formatting the rows so all the fields in each
column line up.
So at the moment I'm
i) Looping over all the objects determining the minimum width of each
column.
ii) Creating a format string with something like String::Format( "{{0,-
{0}}}{{1,-{1}}}{{2,-{2}}}{{3}}\n", columnWidth1, columnWidth2,
columnWidth3);
iii) Then doing pLine += String::Format( pFmt, pLine->Type, pLine-
>Name, pLine->Value, pLine->Desc) +
"\n";
Anyway to make this faster?
StringBuilder.
Forget optimizing anything else if you're not using StringBuilder; rewrite
it to use that first. Concatenating strings in a loop is hugely inefficient.
See http://msdn.microsoft.com/library/2839d5h5 for examples.
--
J.
On Aug 8, 4:45*pm, kelvin.koo...@g ooglemail.com wrote:
Using C++/CLI but I would imagine C# is the same.
What is the fastest to do the following operations
1) Compare two Strings without case-sensitivity.
String.Compare with StringCompare.O rdinalIgnoreCas e
2) Take a group of objects with 4 string fields and tabulate them, so
each field is in a column, in a single String, one line per object
with \n separating them, calculating the minimum width required for
each column and them formatting the rows so all the fields in each
column line up.
So at the moment I'm
i) Looping over all the objects determining the minimum width of each
column.
ii) Creating a format string with something like String::Format( "{{0,-
{0}}}{{1,-{1}}}{{2,-{2}}}{{3}}\n", columnWidth1, columnWidth2,
columnWidth3);
iii) Then doing pLine += String::Format( pFmt, pLine->Type, pLine->Name,* * * * * * * * * * * * * * * *pLine->Value, pLine->Desc) +
"\n";
Anyway to make this faster?
Aside from StringBuilder, there doesn't seem to be much more to
optimize here.
Pavel Minaev wrote:
On Aug 8, 4:45 pm, kelvin.koo...@g ooglemail.com wrote:
>Using C++/CLI but I would imagine C# is the same.
What is the fastest to do the following operations
1) Compare two Strings without case-sensitivity.
String.Compare with StringCompare.O rdinalIgnoreCas e
>2) Take a group of objects with 4 string fields and tabulate them, so each field is in a column, in a single String, one line per object with \n separating them, calculating the minimum width required for each column and them formatting the rows so all the fields in each column line up.
So at the moment I'm i) Looping over all the objects determining the minimum width of each column. ii) Creating a format string with something like String::Format ("{{0,- {0}}}{{1,-{1}}}{{2,-{2}}}{{3}}\n", columnWidth1 , columnWidth2, columnWidth3 ); iii) Then doing pLine += String::Format( pFmt, pLine->Type, pLine->Name, pLine->Value, pLine->Desc) +
"\n";
Anyway to make this faster?
Aside from StringBuilder, there doesn't seem to be much more to
optimize here.
Well, even StringBuilder will grow using that method (although much more
efficiently than looping String::Concat) . However as long as you count the
items in (i), you then know the length of each row, so you can easily
compute the needed capacity and perform only one allocation. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michele Simionato |
last post by:
I posted this few weeks ago (remember the C Sharp thread?) but it went
unnoticed on the large mass of posts, so let me retry. Here I get Python+
Psyco twice as fast as optimized C, so I would like to now if something
is wrong on my old laptop and if anybody can reproduce my results.
Here are I my numbers for calling the error function a million times
(Python 2.3, Psyco 1.0, Red Hat Linux 7.3, Pentium II 366 MHz):
$ time p23 erf.py
real ...
|
by: Alex Vinokur |
last post by:
Consider the following statement:
n+i, where i = 1 or 0.
Is there more fast method for computing n+i than direct computing that sum?
--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
|
by: GS |
last post by:
The stdint.h header definition mentions five integer categories,
1) exact width, eg., int32_t
2) at least as wide as, eg., int_least32_t
3) as fast as possible but at least as wide as, eg., int_fast32_t
4) integer capable of holding a pointer, intptr_t
5) widest integer in the implementation, intmax_t
Is there a valid motivation for having both int_least and int_fast?
|
by: Chad Myers |
last post by:
I've been perf testing an application of mine and I've noticed that there
are a lot (and I mean A LOT -- megabytes and megabytes of 'em) System.String
instances being created.
I've done some analysis and I'm led to believe (but can't yet quantitatively
establish as fact) that the two basic culprits are a lot of calls to:
1.) if( someString.ToLower() == "somestring" )
and
|
by: thecodemachine |
last post by:
Hi,
I'm looking for a fast and simple one to one hash function, suitable
for longer strings (up to 2048 in length). I'd like keys to be
relatively short, I doubt I'd be creating more than 256 keys..
I could use md5 but even that is more than I need, and I assume not the
fastest algorithm (?), so I'm reluctant to use it.
I've been looking around a lot, not finding much anything come to mind?
| |
by: Jean-François Blais |
last post by:
Many must have asked that question. I intend to write a few programs
which will be CPU intensive. I know a little of Java. Would a language
that yields native code, instead of bytecode perfrom much faster?
I recently wrote a minuscule C program containing one loop using a few
variables, and an equivalent java program, which was nearly as fast as
the C program. Unexpected result to me. When is Java slower?
What kind of program will I...
|
by: hstagni |
last post by:
Where can I find a library to created text-based windows applications?
Im looking for a library that can make windows and buttons inside
console.. Many old apps were make like this, i guess
____________________________________
| |
| ------------------ |
| | BUTTON | |
| ...
|
by: Sharath |
last post by:
"Inspired" by the huge success of our first two automation fast track
batches
We are forced to start third fast track automation batch
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++
Course on Automation, QTP Basics and Advanced, Quality Center and
project
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
by: Sharath |
last post by:
We are glad to inform you that
"Inspired" by the huge success of our first three automation fast
track
batches
We are forced to start fourth fast track automation batch
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Course on Automation, QTP Basics and Advanced, Quality Center and
project
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: 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...
| |