This repository was archived by the owner on Dec 1, 2017. It is now read-only.
File tree 5 files changed +68
-1
lines changed
5 files changed +68
-1
lines changed Original file line number Diff line number Diff line change
1
+ randIdGen_exe = executable (' randIdGen' , ' randomIdGen.cpp' )
2
+ benchmark (' randIdGen, not optimized' , randIdGen_exe)
3
+
4
+ op_randIdGen_exe = executable (' op_randIdGen' , ' op_randomIdGen.cpp' )
5
+ benchmark (' op_randIdGen, optimized' , op_randIdGen_exe)
Original file line number Diff line number Diff line change
1
+ #include < random>
2
+ #include < string>
3
+ #include < vector>
4
+
5
+
6
+ void genAndFill (std::vector<std::string> &v)
7
+ {
8
+ std::string ss;
9
+ ss.resize (8 , ' ' );
10
+
11
+ constexpr char alphanum[] = " 0123456789"
12
+ " abcdefghijklmnopqrstuvwxyz"
13
+ " ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
14
+
15
+ static const auto seed = std::random_device ()();
16
+ static std::mt19937 gen (seed);
17
+ std::uniform_int_distribution<> dis (0 , 61 );
18
+
19
+ for (int i = 0 ; i < 8 ; ++i) {
20
+ ss[i] = alphanum[dis (gen)];
21
+ }
22
+ v.push_back (ss);
23
+ }
24
+
25
+ int main ()
26
+ {
27
+ std::vector<std::string> v;
28
+ v.reserve (500000 );
29
+
30
+ for (auto l = 0 ; l < 500000 ; ++l) {
31
+ genAndFill (v);
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ #include < random>
2
+ #include < string>
3
+ #include < vector>
4
+
5
+
6
+ void genAndFill (std::vector<std::string> &v)
7
+ {
8
+ const char alphanum[] = " 0123456789"
9
+ " abcdefghijklmnopqrstuvwxyz"
10
+ " ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
11
+ char ss[8 ];
12
+ std::random_device rd;
13
+ std::mt19937 gen (rd ());
14
+
15
+ for (int i = 0 ; i < 8 ; i++) {
16
+ std::uniform_int_distribution<> dis (0 , 61 );
17
+ ss[i] = alphanum[dis (gen)];
18
+ }
19
+ v.push_back (ss);
20
+ }
21
+
22
+ int main ()
23
+ {
24
+ std::vector<std::string> v;
25
+ for (auto l = 0 ; l < 500000 ; l++) {
26
+ genAndFill (v);
27
+ }
28
+ }
Original file line number Diff line number Diff line change 4
4
5
5
mkdir -p build
6
6
cd build/
7
- (meson --default-library=static .. && ninja) || (ninja && ./test/testexe)
7
+ (meson --default-library=static .. --warnlevel=3 && ninja) || (ninja && ./test/testexe)
Original file line number Diff line number Diff line change 31
31
subdir (' src' )
32
32
subdir (' app' )
33
33
subdir (' test' )
34
+ subdir (' benchmark' )
34
35
35
36
emulate_rasp = find_program (' scripts/emulate_rasp.sh' )
36
37
run_target (' emulate' , command : emulate_rasp.path())
You can’t perform that action at this time.
0 commit comments