Clearmatics Libsnark  0.1
C++ library for zkSNARK proofs
constraint_profiling.hpp
Go to the documentation of this file.
1 
12 #ifndef CONSTRAINT_PROFILING_HPP_
13 #define CONSTRAINT_PROFILING_HPP_
14 
15 #include <cstddef>
16 #include <map>
17 #include <string>
18 #include <vector>
19 
20 namespace libsnark
21 {
22 
23 extern size_t constraint_profiling_indent;
24 
26  size_t indent;
27  std::string annotation;
28  size_t count;
29 };
30 
31 extern std::vector<constraint_profiling_entry> constraint_profiling_table;
32 
33 #define PROFILE_CONSTRAINTS(pb, annotation) \
34  for (size_t _num_constraints_before = pb.num_constraints(), \
35  _iter = (++libsnark::constraint_profiling_indent, 0), \
36  _cp_pos = libsnark::constraint_profiling_table.size(); \
37  _iter == 0; \
38  libsnark::constraint_profiling_table.insert( \
39  libsnark::constraint_profiling_table.begin() + _cp_pos, \
40  libsnark::constraint_profiling_entry{ \
41  --libsnark::constraint_profiling_indent, \
42  annotation, \
43  pb.num_constraints() - _num_constraints_before}), \
44  _iter = 1)
45 
46 size_t PRINT_CONSTRAINT_PROFILING(); // returns # of top level constraints
47 
48 } // namespace libsnark
49 
50 #endif // CONSTRAINT_PROFILING_HPP_
libsnark
Definition: accumulation_vector.hpp:18
libsnark::constraint_profiling_entry
Definition: constraint_profiling.hpp:25
libsnark::constraint_profiling_entry::count
size_t count
Definition: constraint_profiling.hpp:28
libsnark::PRINT_CONSTRAINT_PROFILING
size_t PRINT_CONSTRAINT_PROFILING()
Definition: constraint_profiling.cpp:23
libsnark::constraint_profiling_entry::indent
size_t indent
Definition: constraint_profiling.hpp:26
libsnark::constraint_profiling_table
std::vector< constraint_profiling_entry > constraint_profiling_table
Definition: constraint_profiling.cpp:21
libsnark::constraint_profiling_entry::annotation
std::string annotation
Definition: constraint_profiling.hpp:27
libsnark::constraint_profiling_indent
size_t constraint_profiling_indent
Definition: constraint_profiling.cpp:20