OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "courgette/adjustment_method.h" | 5 #include "courgette/adjustment_method.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include <iostream> | 15 #include <iostream> |
16 | 16 |
17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
18 #include "base/format_macros.h" | 18 #include "base/format_macros.h" |
19 #include "base/logging.h" | 19 #include "base/logging.h" |
20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 21 #include "base/time.h" |
21 | 22 |
22 #include "courgette/assembly_program.h" | 23 #include "courgette/assembly_program.h" |
23 #include "courgette/courgette.h" | 24 #include "courgette/courgette.h" |
24 #include "courgette/encoded_program.h" | 25 #include "courgette/encoded_program.h" |
25 #include "courgette/image_info.h" | 26 #include "courgette/image_info.h" |
26 | 27 |
27 /* | 28 /* |
28 | 29 |
29 Shingle weighting matching. | 30 Shingle weighting matching. |
30 | 31 |
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 ReferenceLabel(rel32, label, is_model); | 1287 ReferenceLabel(rel32, label, is_model); |
1287 } | 1288 } |
1288 // TODO(sra): we could simply append all the labels in index order to | 1289 // TODO(sra): we could simply append all the labels in index order to |
1289 // incorporate some costing for entropy (bigger deltas) that will be | 1290 // incorporate some costing for entropy (bigger deltas) that will be |
1290 // introduced into the label address table by non-monotonic ordering. This | 1291 // introduced into the label address table by non-monotonic ordering. This |
1291 // would have some knock-on effects to parts of the algorithm that work on | 1292 // would have some knock-on effects to parts of the algorithm that work on |
1292 // single-occurrence labels. | 1293 // single-occurrence labels. |
1293 } | 1294 } |
1294 | 1295 |
1295 void Solve(const Trace& model, size_t model_end) { | 1296 void Solve(const Trace& model, size_t model_end) { |
| 1297 base::Time start_time = base::Time::Now(); |
1296 AssignmentProblem a(model, model_end); | 1298 AssignmentProblem a(model, model_end); |
1297 a.Solve(); | 1299 a.Solve(); |
| 1300 LOG(INFO) << " Adjuster::Solve " |
| 1301 << (base::Time::Now() - start_time).InSecondsF(); |
1298 } | 1302 } |
1299 | 1303 |
1300 void ReferenceLabel(Trace* trace, Label* label, bool is_model) { | 1304 void ReferenceLabel(Trace* trace, Label* label, bool is_model) { |
1301 trace->push_back( | 1305 trace->push_back( |
1302 label_info_maker_.MakeLabelInfo(label, is_model, trace->size())); | 1306 label_info_maker_.MakeLabelInfo(label, is_model, trace->size())); |
1303 } | 1307 } |
1304 | 1308 |
1305 AssemblyProgram* prog_; // Program to be adjusted, owned by caller. | 1309 AssemblyProgram* prog_; // Program to be adjusted, owned by caller. |
1306 const AssemblyProgram* model_; // Program to be mimicked, owned by caller. | 1310 const AssemblyProgram* model_; // Program to be mimicked, owned by caller. |
1307 | 1311 |
1308 LabelInfoMaker label_info_maker_; | 1312 LabelInfoMaker label_info_maker_; |
1309 | 1313 |
1310 private: | 1314 private: |
1311 DISALLOW_COPY_AND_ASSIGN(Adjuster); | 1315 DISALLOW_COPY_AND_ASSIGN(Adjuster); |
1312 }; | 1316 }; |
1313 | 1317 |
1314 //////////////////////////////////////////////////////////////////////////////// | 1318 //////////////////////////////////////////////////////////////////////////////// |
1315 | 1319 |
1316 } // namespace adjustment_method_2 | 1320 } // namespace adjustment_method_2 |
1317 | 1321 |
1318 AdjustmentMethod* AdjustmentMethod::MakeShingleAdjustmentMethod() { | 1322 AdjustmentMethod* AdjustmentMethod::MakeShingleAdjustmentMethod() { |
1319 return new adjustment_method_2::Adjuster(); | 1323 return new adjustment_method_2::Adjuster(); |
1320 } | 1324 } |
1321 | 1325 |
1322 } // namespace courgette | 1326 } // namespace courgette |
OLD | NEW |