mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
Core: memeq8len
This commit is contained in:
parent
655233f338
commit
fb1deb732f
6 changed files with 165 additions and 0 deletions
43
benchmarks/memeq8len/memeq8len.cpp
Normal file
43
benchmarks/memeq8len/memeq8len.cpp
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#include <Core/Core.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
size_t memeq8len_e(const void *p, const void *q, size_t count)
|
||||
{
|
||||
const byte *t = (byte *)p;
|
||||
const byte *t0 = t;
|
||||
const byte *s = (byte *)q;
|
||||
const byte *et = t0 + count;
|
||||
|
||||
while(t < et) {
|
||||
if(*t != *s)
|
||||
return t - t0;
|
||||
t++;
|
||||
s++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int len, len2;
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
StdLogSetup(LOG_COUT|LOG_FILE);
|
||||
|
||||
byte a[497], b[497];
|
||||
for(int i = 0; i < 497; i++)
|
||||
a[i] = Random();
|
||||
|
||||
for(int i = 0; i < 10000; i++)
|
||||
for(int i = 0; i < 497; i++) {
|
||||
memcpy(a, b, 497);
|
||||
b[Random(497)] = 13;
|
||||
|
||||
{ RTIMING("memeqlen"); len += memeq8len(a, b, 497); }
|
||||
{ RTIMING("memeqlen_e"); len2 += memeq8len_e(a, b, 497); }
|
||||
|
||||
{ RTIMING("memeqlen1"); len += memeq8len(a + 1, b + 1, 496); }
|
||||
{ RTIMING("memeqlen_e1"); len2 += memeq8len_e(a + 1, b + 1, 496); }
|
||||
}
|
||||
}
|
||||
9
benchmarks/memeq8len/memeq8len.upp
Normal file
9
benchmarks/memeq8len/memeq8len.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
memeq8len.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue