5 #include "HnSparseStress.h"
10 Printf(
"%s v%d.%d.%d-%s", NDMSPC_NAME, NDMSPC_VERSION_MAJOR(NDMSPC_VERSION), NDMSPC_VERSION_MINOR(NDMSPC_VERSION),
11 NDMSPC_VERSION_PATCH(NDMSPC_VERSION), NDMSPC_VERSION_RELEASE);
14 [[noreturn]]
void help(
int rc = 0)
17 Printf(
"\nUsage: [OPTION]...");
19 Printf(
" -d, --dimentsions[=VALUE] number of dimensions (default: 2)");
20 Printf(
" -b, --bins[=VALUE] number of bins per axis (default: 5)");
21 Printf(
" -f, --fill[=VALUE] fill size (default : 1e5)");
22 Printf(
" -s, --start[=VALUE] start (default : 0)");
23 Printf(
" -r, --reserve[=VALUE] reserve bins (default : 0 - nothing is reserved)");
24 Printf(
" -p, --print-refresh[=VALUE] print refresh (default : 1)");
25 Printf(
" -c, --chunk[=VALUE] chunk size (default : 1024*16)");
26 Printf(
" -o, --output[=VALUE] output filename (default: \"\")");
27 Printf(
" -z, --fill-random fill random");
28 Printf(
"\n -h, --help display this help and exit");
29 Printf(
" -v, --version output version information and exit");
30 Printf(
" -x, --debug[=VALUE] debug level");
31 Printf(
"\nExamples:");
32 Printf(
" %s-gen -s 1e5", NDMSPC_NAME);
33 Printf(
" Generate default histogram with 1e5 entries");
34 Printf(
"\nReport bugs at <https://gitlab.com/ndmspc/ndmspc>");
35 Printf(
"General help using GNU software: <https://www.gnu.org/gethelp/>");
39 int main(
int argc,
char ** argv)
45 Int_t nPrintRefresh = 1;
46 std::string filename =
"";
51 Long64_t startFill = 0;
52 std::string start_str;
53 Int_t chunkSize = 1024 * 16;
54 Long64_t nBinsReserved = 0;
55 bool fillRandom =
false;
58 std::string shortOpts =
"hvzd:b:f:s:o:x:r:p:c:W;";
59 struct option longOpts[] = {{
"help", no_argument,
nullptr,
'h'},
60 {
"version", no_argument,
nullptr,
'v'},
61 {
"dims", required_argument,
nullptr,
'd'},
62 {
"bins", required_argument,
nullptr,
'b'},
63 {
"fill", required_argument,
nullptr,
'f'},
64 {
"start", required_argument,
nullptr,
's'},
65 {
"fill-random", no_argument,
nullptr,
'z'},
66 {
"output", required_argument,
nullptr,
'o'},
67 {
"debug", required_argument,
nullptr,
'x'},
68 {
"reserve", required_argument,
nullptr,
'r'},
69 {
"print-refresh", required_argument,
nullptr,
'p'},
70 {
"chunk", required_argument,
nullptr,
'c'},
71 {
nullptr, 0,
nullptr, 0}};
75 nextOption = getopt_long(argc, argv, shortOpts.c_str(), longOpts,
nullptr);
84 case 'd': nDim = atoi(optarg);
break;
85 case 'b': nBins = atoi(optarg);
break;
86 case 'f': nFill = (Long64_t)atof(optarg);
break;
87 case 's': start_str = optarg;
break;
88 case 'o': filename = optarg;
break;
89 case 'x': debug = atoi(optarg);
break;
90 case 'z': fillRandom =
true;
break;
91 case 'r': nBinsReserved = (Long64_t)atof(optarg);
break;
92 case 'p': nPrintRefresh = (Int_t)atof(optarg);
break;
93 case 'c': chunkSize = (Int_t)atof(optarg);
break;
96 }
while (nextOption != -1);
99 if (!start_str.empty()) {
100 if (start_str[start_str.length() - 1] ==
'x') {
101 start_str.pop_back();
102 startFill = (Long64_t)(atof(start_str.data()) * nFill);
105 startFill = (Long64_t)atof(start_str.data());
111 double min = -(Double_t)nBins / 2;
112 double max = (Double_t)nBins / 2;
117 for (Int_t i = 0; i < nDim; i++) {
130 Printf(
"Starting to fill at %lld random=%d...", startFill, fillRandom);
131 if (!stress.
Generate(h, nFill, startFill))
return 1;
133 Long64_t nBinsSizeBytes =
sizeof(Double_t) * h->GetNbins();
135 if (!filename.empty()) {
136 Printf(
"Saving output to file '%s' ...", filename.data());
137 TFile * f = TFile::Open(filename.data(),
"RECREATE");
139 Printf(
"Memory : %03.2f MB (%lld B) File: %03.2f MB (%lld B)", (
double)nBinsSizeBytes / (1024 * 1024),
140 nBinsSizeBytes, (
double)f->GetFileBytesWritten() / (1024 * 1024), f->GetFileBytesWritten());
144 Printf(
"Memory : %03.2f MB (%lld B)", (
double)nBinsSizeBytes / (1024 * 1024), nBinsSizeBytes);
void SetPrintRefresh(Int_t n)
Setting print refresh.
virtual Bool_t Generate(THnSparse *h, Long64_t size=1e3, Long64_t start=1e3)
void SetRandomFill(bool rf)
Setting fill random flag.
void SetDebugLevel(Int_t debug)
Setting debug level.
void ReserveBins(Long64_t nBins)