On Sun, 13 Jun 2004 23:10:04 +0000, Curt Zirzow <[EMAIL PROTECTED]> wrote:
* Thus wrote Alexander Valyalkin ([EMAIL PROTECTED]):
Here is improved version of crc32() function.
Features:
1) Automatic initialization of crc32tab[] at first call.
So, the file crc32.h with definition of this tab is not
nessesary any more now.
I'm not sure what advantage this is really giving you being that
gcc will optimize where the data segment should be, vs putting the
data directly into php's memory.
Yes, it's my fault.
2) Speed is improved on large amount of data.
By using a registered int with a do while() statement vs a
foreach() statement, I'd like to see some benchmarks against this.
Well. Try something like this:
===================cut===================
#include <stdio.h>
#include <time.h> /* for use _rdtsc() */
#define N 10 * 1000 * 1000
int main(int argc,char *argv[])
{
unsigned long long int t;
unsigned int i;
unsigned int crc = ~0;
t = _rdtsc();
for (i = 0; i < N; i++) {
crc ^= i;
}
printf("speed of for (i++) loop: %llu\n", _rdtsc() - t);
i = N;
t = _rdtsc();
for ( ; i--; ) {
crc ^= i;
}
printf("speed of for (i--) loop: %llu\n", _rdtsc() - t);
i = N;
t = _rdtsc();
if (i > 0) do {
crc ^=i;
} while (--i);
printf("speed of do while loop: %llu\n", _rdtsc() - t);
return 0;
}
===================cut===================
--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php