// 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 <stdio.h>
#include <time.h>

#include <iostream>

using namespace std;

// saved time
time_t t;

// start and end of timing
void start(char *hdr)
{
   cout << hdr << endl;
   t = time(NULL);
   return;
}

void end()
{
   cout << (time(NULL)-t) << " seconds" << endl;
   return;
}

int main()
{
   long long tmp;
   // nothing
   tmp = 0;
   start("Nothing");
   for(int j=0;j<10000;j++) {
      for(int i=0;i<1000000;i++) {
         tmp = tmp + i;
      }
   }
   end();
   printf("%d%09d\n",tmp/1000000000,tmp%1000000000);
   // time division
   tmp = 0;
   start("Division");
   for(int j=0;j<10000;j++) {
      for(int i=0;i<1000000;i++) {
         tmp = tmp + (i/256);
      }
   }
   end();
   printf("%d%09d\n",tmp/1000000000,tmp%1000000000);
   // time shift
   tmp = 0;
   start("Shift");
   for(int j=0;j<10000;j++) {
      for(int i=0;i<1000000;i++) {
         tmp = tmp + (i>>8);
      }
   }
   end();
   printf("%d%09d\n",tmp/1000000000,tmp%1000000000);
}
