Skip to content

Commit ad0bc25

Browse files
committed
Improved benchmark code
1 parent 66d66ab commit ad0bc25

38 files changed

Lines changed: 1463 additions & 1808 deletions

eval/eval_exec.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
//#include "algorithms/cutvertex/cv_fact.hpp"
2121
//#include "algorithms/cc/cc.hpp"
22-
//#include "algorithms/matching/matching_fact.hpp"
23-
//#include "algorithms/scc/scc_fact.hpp"
22+
#include "algorithms/matching/matching_fact.hpp"
23+
#include "algorithms/scc/scc_fact.hpp"
2424
//#include "algorithms/toposort/ts_fact.hpp"
2525
#include "eval/eval_exec.hpp"
2626
#include "eval/file_evaluator.hpp"
@@ -55,11 +55,11 @@ void printHeader(Util::prog_opts::variables_map vm)
5555
std::cout << "Set implementation: " << LIB::SET_FACT.kind() << "\n";
5656
std::cout << "PWMap implementation: " << LIB::PWMAP_FACT.kind() << "\n";
5757
std::cout << "-----------------------------------\n";
58-
//std::cout << "Matching algorithm: " << LIB::MATCH_FACT.kind() << "\n";
59-
//std::cout << "SCC algorithm: " << LIB::SCC_FACT.kind() << "\n";
58+
std::cout << "Matching algorithm: " << LIB::MATCH_FACT.kind() << "\n";
59+
std::cout << "SCC algorithm: " << LIB::SCC_FACT.kind() << "\n\n";
6060
//std::cout << "Cut vertex algorithm: " << LIB::CV_FACT.kind() << "\n";
6161
//std::cout << "Topological sort algorithm: " << LIB::TS_FACT.kind()
62-
// << "\n";
62+
// << "\n";
6363
}
6464
std::cout << "-----------------------------------\n";
6565
std::cout << ">>>>>>>>>>> Eval result <<<<<<<<<<<\n";
@@ -88,6 +88,8 @@ EvalExecutor::EvalExecutor() : scc_impl_(1)
8888
"\n - 0 for V1 of minimum reachable SCC"
8989
"\n - 1 for V2 of minimum reachable SCC (default option)");
9090

91+
// First option without name is the input file
92+
_positional.add("input-file", 1);
9193
_cmd_line_opts.add(_generic).add(_config).add(_hidden);
9294
_cfg_file_opts.add(_config).add(_hidden);
9395
_visible.add(_generic).add(_config);
@@ -123,12 +125,12 @@ detail::EvalUserInput EvalExecutor::chooseImplementation()
123125
return result;
124126
}
125127

126-
void EvalExecutor::execute(int arg_count, char* args[])
128+
void EvalExecutor::execute(int argc, char* argv[])
127129
{
128130
// Command line options handling ---------------------------------------------
129131

130132
Util::prog_opts::variables_map vm;
131-
store(Util::prog_opts::command_line_parser(arg_count, args)
133+
store(Util::prog_opts::command_line_parser(argc, argv)
132134
.options(_cmd_line_opts).positional(_positional).run(), vm);
133135
notify(vm);
134136

eval/eval_exec.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ class EvalExecutor : public Util::UserInputHandler {
4949

5050
} // namespace SBG
5151

52-
#endif
52+
#endif // SBGRAPH_EVAL_EVAL_EXEC_HPP_

eval/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#include "eval/eval_exec.hpp"
3131

32-
int main(int argc, char**argv)
32+
int main(int argc, char* argv[])
3333
{
3434
std::cout << std::boolalpha;
3535

eval/pretty_print.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ std::ostream& operator<<(std::ostream& out, const ProgramIO& p);
7474

7575
} // namespace SBG
7676

77-
#endif
77+
#endif // SBGRAPH_EVAL_PRETTY_PRINT_HPP_

eval/user_input.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ class EvalUserInput {
7171

7272
} // namespace SBG
7373

74-
#endif
74+
#endif // SBGRAPH_EVAL_USER_INPUT_HPP_

parser/parser_exec.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ namespace Parser {
3636

3737
ParserExecutor::ParserExecutor() : UserInputHandler()
3838
{
39+
// First option without name is the input file
40+
_positional.add("input-file", 1);
3941
_cmd_line_opts.add(_generic).add(_config).add(_hidden);
4042
_cfg_file_opts.add(_config).add(_hidden);
4143
_visible.add(_generic).add(_config);

sbg/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ target_sources(
2222
ord_set.cpp
2323
ord_unidim_dense_set.cpp
2424
pw_map.cpp
25+
pwmap_detail.cpp
2526
pwmap_fact.cpp
2627
rational.cpp
2728
sbg.cpp

sbg/ord_pwmap.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "sbg/set_fact.hpp"
2121
#include "sbg/ord_pwmap.hpp"
2222

23-
#include <algorithm>
2423
#include <forward_list>
2524
#include <set>
2625
#include <iostream>
@@ -410,15 +409,14 @@ Set OrdPWMap::preImage(const Set& subcodom) const
410409

411410
OrdPWMap OrdPWMap::inverse() const
412411
{
413-
OrdMapCollection result;
412+
OrdPWMap result;
414413

415414
for (const MapEntry& entry : _pieces) {
416415
Map m = entry.map();
417-
result.emplace_back(Map{m.image(), m.law().inverse()});
416+
result.emplace(Map{m.image(), m.law().inverse()});
418417
}
419418

420-
std::sort(result.begin(), result.end());
421-
return OrdPWMap{std::move(result)};
419+
return result;
422420
}
423421

424422
OrdPWMap OrdPWMap::composition(const OrdPWMap& other) const
@@ -589,7 +587,7 @@ OrdPWMap OrdPWMap::reduce() const
589587

590588
for (const MapEntry& entry : _pieces) {
591589
std::vector<Map> reduced = entry.map().reduce();
592-
for(Map& reduced_map : reduced) {
590+
for (Map& reduced_map : reduced) {
593591
result.insert(std::move(reduced_map));
594592
}
595593
}

sbg/ord_pwmap.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class OrdPWMap {
140140

141141
friend class AddCore;
142142
friend class MinAdjCore;
143+
friend class PWMapAccessKey;
143144
};
144145

145146
template<typename... Args>

sbg/pw_map.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ namespace detail {
5151

5252
using PWMapImpl = std::variant<UnordPWMap, OrdPWMap>;
5353

54+
class PWMapAccessKey;
55+
5456
} // namespace detail
5557

5658
enum class PWMapKind { kUnordered, kOrdered, kDomOrdered };
@@ -238,6 +240,8 @@ class PWMap {
238240
PWMap(detail::PWMapImpl&& impl);
239241

240242
detail::PWMapImpl _impl;
243+
244+
friend class detail::PWMapAccessKey;
241245
};
242246

243247
std::ostream& operator<<(std::ostream& out, const PWMap& pw);

0 commit comments

Comments
 (0)