#include #include #include static int nibble(int c) { if(c >= '0' && c <= '9') return c - '0'; if(c < 0x20) c += 0x20; if(c >= 'a' && c <= 'f') return c - 'a'+10; return 0xff; } static void bindigest(char *s, uchar *t) { int i; if(strlen(s) != 2*SHA1dlen) sysfatal("bad digest %s", s); for(i = 0; i < SHA1dlen; i++) t[i] = nibble(s[2*i])<<4 | nibble(s[2*i + 1]); } static char *vs = "vac:da6b4b5549383cffc1b5691d824fc4bd381f0f6b"; void main(void) { int i, n; uchar score[SHA1dlen]; uvlong t0, t1; n = 1000*1000; t0 = nsec(); for(i = 0; i < n; i++){ if(strncmp(vs, "vac:", 4) == 0) bindigest(vs + 4, score); else sysfatal("bad digest"); } t1 = nsec(); print("%g\n", 1.*(t1 - t0)/(1.*n)); exits(""); }