| OLD | NEW |
| 1 # Copyright 2016 the V8 project authors. All rights reserved. | 1 # Copyright 2016 the V8 project 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 import bytecode_dispatches_report as bdr | 5 import bytecode_dispatches_report as bdr |
| 6 import unittest | 6 import unittest |
| 7 | 7 |
| 8 | 8 |
| 9 class BytecodeDispatchesReportTest(unittest.TestCase): | 9 class BytecodeDispatchesReportTest(unittest.TestCase): |
| 10 def test_find_top_counters(self): | 10 def test_find_top_counters(self): |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 "b": {"a": 1, "c": 4}, | 36 "b": {"a": 1, "c": 4}, |
| 37 "c": {"a": 42, "b": 12, "c": 99} | 37 "c": {"a": 42, "b": 12, "c": 99} |
| 38 }) | 38 }) |
| 39 self.assertListEqual(top_dispatch_sources, [ | 39 self.assertListEqual(top_dispatch_sources, [ |
| 40 ('c', 153), | 40 ('c', 153), |
| 41 ('a', 25), | 41 ('a', 25), |
| 42 ('b', 5) | 42 ('b', 5) |
| 43 ]) | 43 ]) |
| 44 | 44 |
| 45 def test_find_top_dispatch_sources(self): | 45 def test_find_top_dispatch_sources(self): |
| 46 top_dispatch_sources = bdr.find_top_dispatch_sources({ | 46 d = { |
| 47 "a": {"a": 10, "b": 8, "c": 7}, | 47 "a": {"a": 4, "b": 2, "c": 4}, |
| 48 "b": {"a": 1, "c": 4}, | 48 "b": {"a": 1, "c": 4}, |
| 49 "c": {"a": 42, "b": 12, "c": 99} | 49 "c": {"a": 40, "b": 10, "c": 50} |
| 50 }, "b", 10) | 50 } |
| 51 self.assertListEqual(top_dispatch_sources, [ | 51 top_sources, top_destinations = bdr.find_top_dispatch_sources(d, "b", 10, Fa
lse) |
| 52 ("c", 12), | 52 self.assertListEqual(top_sources, [ |
| 53 ("a", 8) | 53 ("c", (10, 0.1)), |
| 54 ("a", (2, 0.2)) |
| 54 ]) | 55 ]) |
| 56 top_sources, top_destinations = bdr.find_top_dispatch_sources(d, "b", 10, Tr
ue) |
| 57 self.assertListEqual(top_sources, [ |
| 58 ("a", (2, 0.2)), |
| 59 ("c", (10, 0.1)) |
| 60 ]) |
| OLD | NEW |