Strip extra spaces from code.
[voro++.git] / branches / 2d / examples / timing / timing_test_2d.cc
bloba194820c1b14f9fc6e9d04ab1ac8869c59977c43
1 #include <ctime>
2 using namespace std;
4 #include "voro++_2d.hh"
6 // Set up the number of blocks that the container is divided into. If the
7 // preprocessor variable NNN hasn't been passed to the code, then initialize it
8 // to a good value. Otherwise, use the value that has been passed.
9 #ifndef NNN
10 #define NNN 26
11 #endif
13 // Set the number of particles that are going to be randomly introduced
14 const int particles=100000;
16 // This function returns a random floating point number between 0 and 1
17 double rnd() {return double(rand())/RAND_MAX;}
19 int main() {
20 clock_t start,end;
21 int i;double x,y;
23 // Initialize the container class to be the unit square, with
24 // non-periodic boundary conditions. Divide it into a 6 by 6 grid, with
25 // an initial memory allocation of 16 particles per grid square.
26 container_2d con(0,1,0,1,NNN,NNN,false,false,16);
28 //Randomly add particles into the container
29 for(i=0;i<particles;i++) {
30 x=rnd();
31 y=rnd();
32 con.put(i,x,y);
35 // Store the initial clock time
36 start=clock();
38 // Carry out a dummy computation of all cells in the entire container
39 con.compute_all_cells();
41 // Calculate the elapsed time and print it
42 end=clock();
43 double runtime=double(end-start)/CLOCKS_PER_SEC;
44 printf("%g\n",runtime);