// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cctype>

using namespace std;

int test1(char *s)
{
  int i;
  for(i=0;i<strlen(s);s++) if(!isalnum(s[i])) return 0;
  return 1;
}

int test2(char *s)
{
  int i,len;
  len = strlen(s);
  for(i=0;i<len;s++) if(!isalnum(s[i])) return 0;
  return 1;
}

int main()
{
   int n = 1;
   char *p;
   for(int i=0; i<6; i++)
   {
      n *= 10;
      p = new char[n+1];
      memset(p,'A',n);
      p[n] = '\0';
      clock_t t1 = clock();
      for(int j=0;j<1000;j++) test1(p);
      clock_t t2 = clock();
      clock_t t3 = clock();
      for(int j=0;j<1000;j++) test2(p);
      clock_t t4 = clock();
      delete[] p;
      printf("%6d : %f9.6 %f9.6\n",n,(t2-t1)/1000.0/CLOCKS_PER_SEC,(t4-t3)/1000.0/CLOCKS_PER_SEC);
   }
}
