Re: bytes To Hex



i was able to read your sample code..
thanks again, and i agree about long loops.

if i have a long loop ..i tend to do as little stack pops as i can

tks


"Jeroen Mostert" <jmostert@xxxxxxxxx> wrote in message
news:47a8f7ee$0$85778$e4fe514c@xxxxxxxxxxxxxxxxx
Peter Duniho wrote:
On Tue, 05 Feb 2008 13:21:54 -0800, Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
wrote:

Analizer1 <dvs_bis@xxxxxxxxxxxxx> wrote:
this was my 1st Run at this type of conversion...
so your remarks are welcome...

I Want The Fastest and Tightest Conversion Possible

Oh dear. I sort of figured that would happen. But really, you probably
don't.

Why, out of interest? Just how many of these are you doing? Do you have
specific performance goals in mind? If you're getting the data from
directory services, that's likely to be much, much slower than any of
the conversion mechanisms given here.

Agreed. Jeroen's version is an interesting exercise, but it should
almost never be the case that one would actually need code written like
that.

I know I was being evil by talking about fast code for that (since people
get obsessed with "the fastest code" too easily), but I couldn't help
myself. I did point out that it's highly unlikely that formatting
hexstrings would be a bottleneck for anything. For one thing, you will
presumably want to *send* those hexstrings somewhere, and then you run
smack-dab into I/O, which tends to bottleneck a lot more.

Writing code that's comparatively difficult to understand like that is
only something you should do once you've tried a readable version and
found it to be _the_ bottleneck performance-wise.

Now here's where I'm slightly offended at the suggestion of producing
unreadable code. Most C programmers would agree that my version is a
paragon of readability. :-D

Also, my comment on not using String.Format() in loops if it's obvious to
avoid still stands (and in this case, using BitConverter is pretty
obvious, and fast to boot as a bonus). Extensive string manipulation *can*
become a bottleneck fairly quickly, or even just a noticeable drag, and
StringBuilder isn't a cure-all for string performance problems.

--
J.


.



Relevant Pages

  • Re: Code Comprehension
    ... procedure Remove_Unique (Target: in out String; ... for J in Source'range loop ... As to readability, it ... depends on how well you know Perl. ...
    (comp.programming)
  • Re: bytes To Hex
    ... I Want The Fastest and Tightest Conversion Possible ... For one thing, you will presumably want to *send* those hexstrings somewhere, and then you run smack-dab into I/O, which tends to bottleneck a lot more. ... Most C programmers would agree that my version is a paragon of readability. ... Extensive string manipulation *can* become a bottleneck fairly quickly, or even just a noticeable drag, and StringBuilder isn't a cure-all for string performance problems. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Fast way to read string one char at a time
    ... > string one char at a time. ... > fairly good idea as to why the "for" loop is fast. ... > string given an char index. ... readability, and only evaluating for peformance _where needed_. ...
    (microsoft.public.dotnet.framework.performance)
  • Re: Loop optimization
    ... I don't think I'd write either loop. ... string, ... If it does turn out to be the bottleneck, ... discover that only by measurement -- and the measurement (and ...
    (comp.lang.c)
  • Re: String builder
    ... *total* size of the array, not the size of the first dimension). ... Benchmark them - have a *big* array, and convert it to a string many ... Are you convinced this is a bottleneck in your ... It's worth concentrating on readability over ...
    (microsoft.public.dotnet.languages.csharp)

Quantcast