/usr/share/siscone/examples/times.cpp is in siscone-examples 2.0.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | ///////////////////////////////////////////////////////////////////////////////
// File: times.cpp //
// Description: example program that computes execution times //
// This file is part of the SISCone project. //
// For more details, see http://projects.hepforge.org/siscone //
// //
// Copyright (c) 2006 Gavin Salam and Gregory Soyez //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
// //
// $Revision:: 320 $//
// $Date:: 2011-11-15 09:54:50 +0100 (Tue, 15 Nov 2011) $//
///////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <iostream>
#include <math.h>
#include "siscone/momentum.h"
#include "siscone/siscone.h"
#define Nruns 32
#define R 0.7
#define f 0.5
using namespace std;
using namespace siscone;
timeval time_start, time_end;
// compute time spent between time_start and time_end
int time_spent(){
timeval time_diff;
// compute different with initial time
time_diff.tv_sec = time_end.tv_sec-time_start.tv_sec;
if (time_end.tv_usec > time_start.tv_usec){
time_diff.tv_usec = time_end.tv_usec-time_start.tv_usec;
} else {
time_diff.tv_sec--;
time_diff.tv_usec = (1000000+time_end.tv_usec)-time_start.tv_usec;
}
return 1000000*time_diff.tv_sec+time_diff.tv_usec;
}
int main(){
vector<Cmomentum> particles;
Csiscone siscone;
double eta,phi;
// number of events and particles
int i, N;
int n_ev, part_inc;
// time statistics variables
int time_siscone;
// save files
FILE *flux;
// initialise random number generator
cout << "initialise random number generator" << endl;
timeval timestamp;
gettimeofday(×tamp, NULL);
srand(timestamp.tv_usec);
flux = fopen("times.dat", "w+");
N = 1;
part_inc = 1;
do{
fprintf(stdout, "\r%5d particles\n", N);
time_siscone=0;
for (n_ev=0;n_ev<Nruns;n_ev++){
// build particle list
particles.clear();
for (i=0;i<N;i++){
eta = -3.0+6.0*rand()/(RAND_MAX+1.0);
phi = 2.0*M_PI*rand()/(RAND_MAX+1.0);
particles.push_back(Cmomentum(cos(phi), sin(phi), tanh(eta), 1.0));
}
// run siscone
gettimeofday(&time_start, NULL);
siscone.compute_jets(particles, R, f);
gettimeofday(&time_end, NULL);
time_siscone+=time_spent();
}
fprintf(flux, "%d\t%e\n", N, time_siscone/(1.0*Nruns));
N+=part_inc;
if (N==(part_inc<<3))
part_inc <<= 1;
// } while (N<=1024);
} while (N<=1024);
fclose(flux);
fprintf(stdout, "\n");
cout << "bye..." << endl;
return 0;
}
|