summaryrefslogtreecommitdiff
path: root/src/passes/Metrics.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-01-27 19:44:11 -0800
committerAlon Zakai <alonzakai@gmail.com>2016-01-27 19:44:11 -0800
commitbe3ee4d97e81af88dcc9ac97b86da53d0d49c302 (patch)
tree7f1c8ce765adb2e306169b64a3db71f18951a581 /src/passes/Metrics.cpp
parent6f0e64113c98dec8fa32270b7c7556ce266190a3 (diff)
downloadbinaryen-be3ee4d97e81af88dcc9ac97b86da53d0d49c302.tar.gz
binaryen-be3ee4d97e81af88dcc9ac97b86da53d0d49c302.tar.bz2
binaryen-be3ee4d97e81af88dcc9ac97b86da53d0d49c302.zip
sort keys in metrics
Diffstat (limited to 'src/passes/Metrics.cpp')
-rw-r--r--src/passes/Metrics.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/passes/Metrics.cpp b/src/passes/Metrics.cpp
index 3624786a4..03f8bc447 100644
--- a/src/passes/Metrics.cpp
+++ b/src/passes/Metrics.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <algorithm>
#include <iomanip>
#include <pass.h>
#include <wasm.h>
@@ -38,13 +39,21 @@ struct Metrics : public WalkerPass<WasmWalker<Metrics>> {
ostream &o = cout;
o << "Counts"
<< "\n";
- for (auto i = counts.cbegin(); i != counts.cend(); i++) {
- o << " " << left << setw(15) << i->first << ": " << setw(8)
- << i->second;
+ vector<const char*> keys;
+ for (auto i : counts) {
+ keys.push_back(i.first);
+ }
+ sort(keys.begin(), keys.end(), [](const char* a, const char* b) -> bool {
+ return strcmp(b, a) > 0;
+ });
+ for (auto* key : keys) {
+ auto value = counts[key];
+ o << " " << left << setw(15) << key << ": " << setw(8)
+ << value;
if (lastMetricsPass) {
- if (lastMetricsPass->counts.count(i->first)) {
- int before = lastMetricsPass->counts[i->first];
- int after = i->second;
+ if (lastMetricsPass->counts.count(key)) {
+ int before = lastMetricsPass->counts[key];
+ int after = value;
if (after - before) {
if (after > before) {
Colors::red(o);