Пример #1
0
 def test_simulate_logged(self):
     a_font_loader = font_loader.FontLoader("fonts/are/here")
     self.assertEqual(
         simulation.simulate_sequence(
             self.page_view_sequence, self.mock_logged_pfe_method,
             simulation.NetworkModel("slow", 0, 10, 10), a_font_loader),
         [self.graph_1])
     self.mock_logged_pfe_method.start_session.assert_called_once_with(
         simulation.NetworkModel("slow", 0, 10, 10), a_font_loader)
     self.mock_logged_pfe_session.page_view_proto.assert_has_calls(
         [mock.call(page_view) for page_view in self.page_view_sequence])
     self.mock_logged_pfe_session.get_request_graphs.assert_called_once_with(
     )
Пример #2
0
    def setUp(self):
        self.net_model = simulation.NetworkModel(name="NetModel",
                                                 rtt=50,
                                                 bandwidth_up=100,
                                                 bandwidth_down=200,
                                                 category="New",
                                                 weight=1)

        self.graph_1 = request_graph.RequestGraph({
            request_graph.Request(1000, 1000),
        })
        self.mock_pfe_method = MockPfeMethod()
        self.mock_pfe_session = MockPfeSession()
        self.mock_pfe_method.name = mock.MagicMock(return_value="Mock_PFE_1")
        self.mock_pfe_method.start_session = mock.MagicMock(
            return_value=self.mock_pfe_session)
        self.mock_pfe_session.page_view = mock.MagicMock(
            side_effect=mock_pfe_session_page_view)
        self.mock_pfe_session.get_request_graphs = mock.MagicMock(
            return_value=[self.graph_1])

        graph_2 = request_graph.RequestGraph({
            request_graph.Request(1000, 1000),
        })
        self.mock_pfe_method_2 = MockPfeMethod()
        self.mock_pfe_session_2 = MockPfeSession()
        self.mock_pfe_method_2.name = mock.MagicMock(return_value="Mock_PFE_2")
        self.mock_pfe_method_2.start_session = mock.MagicMock(
            return_value=self.mock_pfe_session_2)
        self.mock_pfe_session_2.page_view = mock.MagicMock()
        self.mock_pfe_session_2.get_request_graphs = mock.MagicMock(
            return_value=[graph_2] * 2)

        self.mock_logged_pfe_method = MockPfeMethod()
        self.mock_logged_pfe_session = MockLoggedPfeSession()
        self.mock_logged_pfe_method.name = mock.MagicMock(
            return_value="Logged_PFE")
        self.mock_logged_pfe_method.start_session = mock.MagicMock(
            return_value=self.mock_logged_pfe_session)
        self.mock_logged_pfe_session.page_view_proto = mock.MagicMock()
        self.mock_logged_pfe_session.get_request_graphs = mock.MagicMock(
            return_value=[self.graph_1])

        self.page_view_sequence = sequence([
            {
                "roboto": [1, 2, 3],
                "open_sans": [4, 5, 6]
            },
            {
                "roboto": [7, 8, 9]
            },
            {
                "open_sans": [10, 11, 12]
            },
        ])
Пример #3
0
 def test_simulate_all(self):
     self.maxDiff = None  # pylint: disable=invalid-name
     graph = simulation.GraphTotal(100.0, 1000, 1000, 1)
     graph2 = simulation.GraphTotal(200.0, 1000, 1000, 1)
     self.assertEqual(
         simulation.simulate_all(
             [
                 pv_sequence(sequence([{
                     "roboto": [1]
                 }, {
                     "roboto": [2]
                 }])),
                 pv_sequence(sequence([{
                     "roboto": [1]
                 }, {
                     "roboto": [2]
                 }])),
             ],
             [
                 self.mock_pfe_method,
                 self.mock_pfe_method_2,
             ],
             [
                 simulation.NetworkModel("slow", 0, 10, 10, "slow", 1),
                 simulation.NetworkModel("fast", 0, 20, 20, "fast", 1),
             ],
             "fonts/are/here",
         ),
         simulation.SimulationResults(
             {
                 "Mock_PFE_1": {
                     "slow": [simulation.SequenceTotals([graph2], 42)] * 2,
                     "fast": [simulation.SequenceTotals([graph], 42)] * 2,
                 },
                 "Mock_PFE_2": {
                     "slow":
                     [simulation.SequenceTotals([graph2] * 2, 42)] * 2,
                     "fast":
                     [simulation.SequenceTotals([graph] * 2, 42)] * 2,
                 },
             }, []))
Пример #4
0
 def test_simulate(self):
     a_font_loader = font_loader.FontLoader("fonts/are/here")
     self.assertEqual(
         simulation.simulate_sequence(
             self.page_view_sequence, self.mock_pfe_method,
             simulation.NetworkModel("slow", 0, 10, 10), a_font_loader),
         [self.graph_1])
     self.mock_pfe_method.start_session.assert_called_once_with(
         simulation.NetworkModel("slow", 0, 10, 10), a_font_loader)
     usage = namedtuple("Usage", ["codepoints", "glyph_ids"])
     self.mock_pfe_session.page_view.assert_has_calls([
         mock.call({
             "roboto": usage({1, 2, 3}, set()),
             "open_sans": usage({4, 5, 6}, set()),
         }),
         mock.call({
             "roboto": usage({7, 8, 9}, set()),
         }),
         mock.call({"open_sans": usage({10, 11, 12}, set())})
     ])
     self.mock_pfe_session.get_request_graphs.assert_called_once_with()
Пример #5
0
ESTIMATED_HTTP_REQUEST_HEADER_SIZE = 35

# Estimated size of a http response header in bytes for a HTTP2 response using HPACK.
ESTIMATED_HTTP_RESPONSE_HEADER_SIZE = 35

# The following network models were derived from browser reported connection speeds (from Chrome)
# across a variety of connection types. For each connection type 5 different speeds are provided
# ranging from the slowest observed speeds to the fastest for that connection type.

# Upload and Download speeds are specified in bytes per millisecond.

# Mobile 2G

MOBILE_2G_SLOWEST = simulation.NetworkModel("mobile_2g_slowest",
                                            rtt=10000,
                                            bandwidth_up=4,
                                            bandwidth_down=4,
                                            category="2G",
                                            weight=0.05)

MOBILE_2G_SLOW = simulation.NetworkModel("mobile_2g_slow",
                                         rtt=4500,
                                         bandwidth_up=6,
                                         bandwidth_down=6,
                                         category="2G",
                                         weight=0.2)

MOBILE_2G_MEDIAN = simulation.NetworkModel("mobile_2g_median",
                                           rtt=2750,
                                           bandwidth_up=9,
                                           bandwidth_down=9,
                                           category="2G",
Пример #6
0
# This estimate is the steady state size, the size of an average request after
# several previous requests have been made and the header dictionary has been
# populated.
ESTIMATED_HTTP_REQUEST_HEADER_SIZE = 35

# Estimated size of a http response header in bytes for a HTTP2 response using HPACK.
ESTIMATED_HTTP_RESPONSE_HEADER_SIZE = 35

# The following network models were derived from browser reported connection speeds (from Chrome)
# across a variety of connection types. For each connection type 5 different speeds are provided
# ranging from the slowest observed speeds to the fastest for that connection type.

# Mobile 2G

MOBILE_2G_SLOWEST = simulation.NetworkModel("mobile_2g_slowest",
                                            rtt=10000,
                                            bandwidth_up=4,
                                            bandwidth_down=4)

MOBILE_2G_SLOW = simulation.NetworkModel("mobile_2g_slow",
                                         rtt=4500,
                                         bandwidth_up=6,
                                         bandwidth_down=6)

MOBILE_2G_MEDIAN = simulation.NetworkModel("mobile_2g_median",
                                           rtt=2750,
                                           bandwidth_up=9,
                                           bandwidth_down=9)

MOBILE_2G_FAST = simulation.NetworkModel("mobile_2g_fast",
                                         rtt=1500,
                                         bandwidth_up=19,