#include "bench.h" #include #include int test_builtin_ffs(int rc) { int c; for (c=0; c<512; c++) { rc += ffs(rc); rc += ffs(rc+1); rc += ffs(rc+2); rc += ffs(rc+3); rc += ffs(rc+4); rc += ffs(rc+5); rc += ffs(rc+6); rc += ffs(rc+7); rc += ffs(rc << 8); rc += ffs(rc << 10); rc += ffs(rc << 12); rc += ffs(rc << 14); rc += ffs(rc << 16); rc += ffs(rc << 8); rc += ffs(rc << 10); rc += ffs(rc << 12); rc += ffs(rc << 14); rc += ffs(rc << 16); rc += ffs(rc << 8); rc += ffs(rc << 10); rc += ffs(rc << 12); rc += ffs(rc << 14); rc += ffs(rc << 16); rc += ffs(rc); rc += ffs(rc+1); rc += ffs(rc+2); rc += ffs(rc+3); rc += ffs(rc+4); rc += ffs(rc+5); rc += ffs(rc+6); rc += ffs(rc+7); } return rc; } char buffer[1024 * 128]; void test_builtin_index(int c) { index(buffer+c*128, 'X'); index(buffer+c*128, 'Y'); rindex(buffer+c*128, 'X'); } void test_builtin_memset(int c) { static char b1[512 * 128]; static char b2[512 * 128]; memset(b1, 0, c*128); memset(b2, 23, c*128); memcmp(b1, b2, c*128); swab(b1, b2, c*128); memcmp(b1, b2, c*128); memfrob(b2, c*128); memchr(b2, 0, c*128); } void test_builtin() { int c; for (c=0; c<1024*128; c++) buffer[c]='a'+c%26; buffer[c/2]='X'; buffer[c-2]='Y'; buffer[c-1]=0; timer_start(CONTEXT_LOCAL); result_push(CONTEXT_LOCAL, 39); for (c=0; c<1024; c++) { result_push(CONTEXT_LOCAL, test_builtin_ffs(c) ); test_builtin_index(c); test_builtin_memset(c); } timer_stop(CONTEXT_LOCAL); }