
#include <ctime>
#include <cstdlib>
#include <iostream>
using namespace std;


#include <aclock.h>
#include <clockmisc.h>

/*
void generateRandomSeed()
{
  srand( time(NULL) );
}
*/

// The variation is still small, on my computer
//   between 3000 loops for 10 and 100 ms wait.

int generateRandomSeed(double const waitms)
{
  double tm = 0.0;

  aclock clk;

  clk.measure();

  int sd=0;

  int kmax;

  int loops=0;

  for ( ;tm<waitms; )
  {
    kmax = rand() % 20;
    for (int k=1; k<kmax; ++k) 
      sd += rand();

    clk.measure();
    tm += clk.diff_ms();

    ++loops;
  }

  if (sd<0)
    sd *= -1;

//  cout << "loops=" << loops << endl;
//  cout << "sd=" << sd << endl;

  return sd;
}





