Functions
test_persist.cxx File Reference
#include "WireCellUtil/Persist.h"
#include <random>
#include <iostream>
#include <functional>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 10 of file test_persist.cxx.

11 {
12  std::string name = argv[0];
13 
14  std::default_random_engine generator;
15  std::uniform_real_distribution<double> distribution(0.0,1.0);
16  auto uni = std::bind(distribution, generator);
17 
18  const int nbins = 500;
19  const int narrays = 100;
20  Json::Value jroot;
21  for (int ind=0; ind<narrays; ++ind) {
22  Json::Value jarr;
23  for (int ibin=0; ibin<nbins; ++ibin) {
24  auto number = uni();
25  jarr.append(number);
26  }
27  jroot[ind] = jarr;
28  }
29 
30  // dump non-pretty in plain text and bzip2'ed to see size diff
31  Persist::dump(name + ".json", jroot);
32  Persist::dump(name + "-ugly.json.bz2", jroot);
33 
34  // dump pretty, read back and redump so can do a diff
35  Persist::dump(name + "-pretty.json", jroot, true);
36  Persist::dump(name + "-pretty.json.bz2", jroot, true);
37 
38  Json::Value jroot2 = Persist::load(name + "-pretty.json");
39  Json::Value jroot3 = Persist::load(name + "-pretty.json.bz2");
40 
41  Persist::dump(name + "-pretty2.json", jroot2, true);
42  Persist::dump(name + "-pretty3.json", jroot3, true);
43  return 0;
44 
45 }
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition: document.h:2106
generator
Definition: train.py:468
void dump(const IFrame::pointer frame)
Definition: Fourdee.cxx:120
def load(filename, jpath="depos")
Definition: depos.py:34