Hi,
I just saw that the author of my books is doing a string comparison via scasb, I tried it via a simple cmp and think that my way should be a bit faster. Now I need some way to check this...

Can someone please give some hints about this? What can be measured? Only time? And please give a little example how to do it, I think that it shouldn't be too complex :)

Thanks!
Posted on 2002-04-26 03:44:28 by Matthias Pfau
scasb is somewhat slow...
The best whay, imho, to implement a strcmp is to use esi and edi registers to point to the strings to compare and then use an index register to compare each character and increment the index register if the two characters are equal...

There's many optimization opportunities when you implement though... and more complex algorithm (example : compare 4 bytes in a row).
You can mesure code in ms (GetTickCount) or in cycles (rdtsc).
Maverick did a very good profiling macro... You can get it at the Algorithm section.

The benchmarking was frenquently discussed on the algorithm section and you will find some useful snippets on it.
Posted on 2002-04-26 04:01:50 by JCP
scasb is somewhat slow...
The best whay, imho, to implement a strcmp is to use esi and edi registers to point to the strings to compare and then use an index register to compare each character and increment the index register if the two characters are equal...

Pretty cool, that was exactly what I have done :)
But it was more luck than knowledge :D

There's many optimization opportunities when you implement though... and more complex algorithm (example : compare 4 bytes in a row).
You can mesure code in ms (GetTickCount) or in cycles (rdtsc).
Maverick did a very good profiling macro... You can get it at the Algorithm section.

The benchmarking was frenquently discussed on the algorithm section and you will find some useful snippets on it.

Ok, will have a look at it :)
Posted on 2002-04-26 04:12:21 by Matthias Pfau
Also, if you post your code in the algorithm section, some optimizations gurus will help you to make it shorter and faster... ;)
Posted on 2002-04-26 05:03:13 by JCP
Yup, will try that after I got a bit more experienced :)
Posted on 2002-04-26 05:35:38 by Matthias Pfau
Huh, I think I'm a bit stupid this morning :(

Can't find a post which explains the use of GetTickCount and rdtsc...even the Intel manual (only found something about rdtsc) didn't help :(

So I would be really glad If someone could explain these two instructions to me (don't make it to complicated, you know I'm very new to this...)

Thanks!
Posted on 2002-04-26 05:55:15 by Matthias Pfau
have a look here at least i think Readiosys means that one
link

hopefully the link works ;)
if not try a search on the board for maverick as nick
Posted on 2002-04-26 08:54:28 by Allanon
Thanks, but I still don't got it :(

I finally found out that GetTickCount is an API function...I'm still at DOS so that doesn't help. I'll have a look at rdtsc tomorrow or after my exams, found some literature about it :)

Good night!
Posted on 2002-04-26 16:34:02 by Matthias Pfau