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/>");
39int 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[] = {
60 {
"help", no_argument,
nullptr,
'h'}, {
"version", no_argument,
nullptr,
'v'},
61 {
"dims", required_argument,
nullptr,
'd'}, {
"bins", required_argument,
nullptr,
'b'},
62 {
"fill", required_argument,
nullptr,
'f'}, {
"start", required_argument,
nullptr,
's'},
63 {
"fill-random", no_argument,
nullptr,
'z'},
64 {
"output", required_argument,
nullptr,
'o'}, {
"debug", required_argument,
nullptr,
'x'},
65 {
"reserve", required_argument,
nullptr,
'r'}, {
"print-refresh", required_argument,
nullptr,
'p'},
66 {
"chunk", required_argument,
nullptr,
'c'}, {
nullptr, 0,
nullptr, 0}};
70 nextOption = getopt_long(argc, argv, shortOpts.c_str(), longOpts,
nullptr);
79 case 'd': nDim = atoi(optarg);
break;
80 case 'b': nBins = atoi(optarg);
break;
81 case 'f': nFill = (Long64_t)atof(optarg);
break;
82 case 's': start_str = optarg;
break;
83 case 'o': filename = optarg;
break;
84 case 'x': debug = atoi(optarg);
break;
85 case 'z': fillRandom =
true;
break;
86 case 'r': nBinsReserved = (Long64_t)atof(optarg);
break;
87 case 'p': nPrintRefresh = (Int_t)atof(optarg);
break;
88 case 'c': chunkSize = (Int_t)atof(optarg);
break;
91 }
while (nextOption != -1);
94 if (!start_str.empty()) {
95 if (start_str[start_str.length() - 1] ==
'x') {
97 startFill = (Long64_t)(atof(start_str.data()) * nFill);
100 startFill = (Long64_t)atof(start_str.data());
106 double min = -(Double_t)nBins / 2;
107 double max = (Double_t)nBins / 2;
112 for (Int_t i = 0; i < nDim; i++) {
124 Printf(
"Starting to fill at %lld random=%d...", startFill, fillRandom);
125 if (!stress.
Generate(h, nFill, startFill))
return 1;
127 Long64_t nBinsSizeBytes =
sizeof(Double_t) * h->GetNbins();
129 if (!filename.empty()) {
130 Printf(
"Saving output to file '%s' ...", filename.data());
131 TFile * f = TFile::Open(filename.data(),
"RECREATE");
133 Printf(
"Memory : %03.2f MB (%lld B) File: %03.2f MB (%lld B)", (
double)nBinsSizeBytes / (1024 * 1024),
134 nBinsSizeBytes, (
double)f->GetFileBytesWritten() / (1024 * 1024), f->GetFileBytesWritten());
138 Printf(
"Memory : %03.2f MB (%lld B)", (
double)nBinsSizeBytes / (1024 * 1024), nBinsSizeBytes);
void SetRandomFill(bool rf)
Setting fill random flag.
virtual Bool_t Generate(THnSparse *h, Long64_t size=1e3, Long64_t start=1e3)
void SetDebugLevel(Int_t debug)
Setting debug level.
void SetPrintRefresh(Int_t n)
Setting print refresh.
void ReserveBins(Long64_t nBins)