Exemplo n.º 1
0
    def testRunGroupSanity(self):
        files = []
        # Generate 20 sets of files in groups separated by 60s.
        for ts_base in xrange(0, 20):
            ts = ts_base * 60
            files.extend([
                ProfileFile(ts, 0, 'browser'),
                ProfileFile(ts + 1, 0, 'renderer'),
                ProfileFile(ts + 2, 1, 'browser'),
                ProfileFile(ts + 3, 0, 'gpu'),
                ProfileFile(ts + 2, 1, 'renderer'),
                ProfileFile(ts + 5, 1, 'gpu')
            ])
        # The following call should not assert.
        process_profiles.ProfileManager(files)._ComputeRunGroups()

        files.extend([
            ProfileFile(20 * 60, 0, 'browser'),
            ProfileFile(20 * 60 + 2, 1, 'renderer'),
            ProfileFile(21 * 60, 0, 'browser')
        ] + [ProfileFile(22 * 60, 0, 'renderer') for _ in xrange(0, 10)])

        self.assertRaises(
            AssertionError,
            process_profiles.ProfileManager(files)._ComputeRunGroups)
Exemplo n.º 2
0
 def testPhases(self):
   mgr = TestProfileManager({
       ProfileFile(40, 0): [],
       ProfileFile(150, 0): [],
       ProfileFile(30, 1): [],
       ProfileFile(30, 2): [],
       ProfileFile(30, 0): []})
   self.assertEquals(set([0,1,2]), mgr.GetPhases())
Exemplo n.º 3
0
 def testReadOffsets(self):
   mgr = TestProfileManager({
       ProfileFile(30, 0): [1, 3, 5, 7],
       ProfileFile(40, 1): [8, 10],
       ProfileFile(50, 0): [13, 15]})
   self.assertListEqual([1, 3, 5, 7, 8, 10, 13, 15],
                        mgr.GetMergedOffsets())
   self.assertListEqual([8, 10], mgr.GetMergedOffsets(1))
   self.assertListEqual([], mgr.GetMergedOffsets(2))
Exemplo n.º 4
0
 def testSorted(self):
   # The fact that the ProfileManager sorts by filename is implicit in the
   # other tests. It is tested explicitly here.
   mgr = TestProfileManager({
       ProfileFile(40, 0): [1, 2, 3, 4],
       ProfileFile(150, 0): [9, 11, 13],
       ProfileFile(30, 1): [5, 6, 7]})
   offsets_list = mgr.GetRunGroupOffsets()
   self.assertEquals(2, len(offsets_list))
   self.assertListEqual([5, 6, 7, 1, 2, 3, 4], offsets_list[0])
Exemplo n.º 5
0
 def testRunGroupOffsets(self):
   mgr = TestProfileManager({
       ProfileFile(30, 0): [1, 2, 3, 4],
       ProfileFile(150, 0): [9, 11, 13],
       ProfileFile(40, 1): [5, 6, 7]})
   offsets_list = mgr.GetRunGroupOffsets()
   self.assertEquals(2, len(offsets_list))
   self.assertListEqual([1, 2, 3, 4, 5, 6, 7], offsets_list[0])
   self.assertListEqual([9, 11, 13], offsets_list[1])
   offsets_list = mgr.GetRunGroupOffsets(0)
   self.assertEquals(2, len(offsets_list))
   self.assertListEqual([1, 2, 3, 4], offsets_list[0])
   self.assertListEqual([9, 11, 13], offsets_list[1])
   offsets_list = mgr.GetRunGroupOffsets(1)
   self.assertEquals(2, len(offsets_list))
   self.assertListEqual([5, 6, 7], offsets_list[0])
   self.assertListEqual([], offsets_list[1])
Exemplo n.º 6
0
    def testClusterOffsets(self):
        processor = TestSymbolOffsetProcessor([
            SimpleTestSymbol('linker_script_start_of_text', 0, 0),
            SimpleTestSymbol('1', 1000, 999),
            SimpleTestSymbol('2', 2000, 999),
            SimpleTestSymbol('3', 3000, 999),
            SimpleTestSymbol('4', 4000, 16),
            SimpleTestSymbol('5', 5000, 16),
            SimpleTestSymbol('6', 6000, 999),
            SimpleTestSymbol('7', 7000, 16),
            SimpleTestSymbol('8', 8000, 999),
            SimpleTestSymbol('9', 9000, 16),
        ])
        mgr = TestProfileManager({
            ProfileFile(40, 0, ''): [1000, 2000, 3000],
            ProfileFile(50, 1, ''): [3000, 4000, 5000],
            ProfileFile(51, 0, 'renderer'): [2000, 3000, 6000],
            ProfileFile(51, 1, 'gpu-process'): [6000, 7000],
            ProfileFile(70, 0, ''): [1000, 2000, 6000, 8000, 9000],
            ProfileFile(70, 1, ''): [9000, 5000, 3000]
        })
        syms = cluster.ClusterOffsets(mgr, processor, limit_cluster_size=False)
        self.assertListEqual(list('236148957'), syms)

        syms = cluster.ClusterOffsets(mgr, processor, limit_cluster_size=True)
        self.assertListEqual(list('236489517'), syms)
Exemplo n.º 7
0
 def testGetAnnotatedOffsets(self):
   mgr = TestProfileManager({
       ProfileFile(40, 0, ''): [1, 2, 3],
       ProfileFile(50, 1, ''): [3, 4, 5],
       ProfileFile(51, 0, 'renderer'): [2, 3, 6],
       ProfileFile(51, 1, 'gpu-process'): [6, 7],
       ProfileFile(70, 0, ''): [2, 8, 9],
       ProfileFile(70, 1, ''): [9]})
   offsets = mgr.GetAnnotatedOffsets()
   self.assertListEqual([
       self.MakeAnnotatedOffset(1, {(0, 'browser'): 1}),
       self.MakeAnnotatedOffset(2, {(0, 'browser'): 2,
                                    (0, 'renderer'): 1}),
       self.MakeAnnotatedOffset(3, {(0, 'browser'): 1,
                                    (1, 'browser'): 1,
                                    (0, 'renderer'): 1}),
       self.MakeAnnotatedOffset(4, {(1, 'browser'): 1}),
       self.MakeAnnotatedOffset(5, {(1, 'browser'): 1}),
       self.MakeAnnotatedOffset(6, {(0, 'renderer'): 1,
                                    (1, 'gpu-process'): 1}),
       self.MakeAnnotatedOffset(7, {(1, 'gpu-process'): 1}),
       self.MakeAnnotatedOffset(8, {(0, 'browser'): 1}),
       self.MakeAnnotatedOffset(9, {(0, 'browser'): 1,
                                    (1, 'browser'): 1})],
                        offsets)
   self.assertListEqual(['browser', 'renderer'],
                        sorted(offsets[1].Processes()))
   self.assertListEqual(['browser'], list(offsets[0].Processes()))
   self.assertListEqual([0], list(offsets[1].Phases()))
   self.assertListEqual([0, 1], sorted(offsets[2].Phases()))
   self.assertListEqual([0, 1], sorted(mgr.GetPhases()))
Exemplo n.º 8
0
 def testGetOrderfilePhaseOffsets(self):
   mgr = TestProfileManager({
       ProfileFile(0, 0): [12, 21, -1, 33],
       ProfileFile(0, 1): [31, 49, 52],
       ProfileFile(100, 0): [113, 128],
       ProfileFile(200, 1): [132, 146],
       ProfileFile(300, 0): [19, 20, 32],
       ProfileFile(300, 1): [24, 39]})
   phaser = phased_orderfile.PhasedAnalyzer(mgr, Mod10Processor())
   opo = lambda s, c, i: phased_orderfile.OrderfilePhaseOffsets(
       startup=s, common=c, interaction=i)
   self.assertListEqual([opo([10, 20], [30], [40, 50]),
                         opo([110, 120], [], []),
                         opo([], [], [130, 140]),
                         opo([10], [20, 30], [])],
                        phaser._GetOrderfilePhaseOffsets())
Exemplo n.º 9
0
 def testRunGroups(self):
   files = [ProfileFile(40, 0), ProfileFile(100, 0),
            ProfileFile(200, 1), ProfileFile(35, 1),
            ProfileFile(42, 0), ProfileFile(95, 0)]
   mgr = process_profiles.ProfileManager(files)
   mgr._ComputeRunGroups()
   self.assertEquals(3, len(mgr._run_groups))
   self.assertEquals(3, len(mgr._run_groups[0].Filenames()))
   self.assertEquals(2, len(mgr._run_groups[1].Filenames()))
   self.assertEquals(1, len(mgr._run_groups[2].Filenames()))
   self.assertTrue(files[0] in mgr._run_groups[0].Filenames())
   self.assertTrue(files[3] in mgr._run_groups[0].Filenames())
   self.assertTrue(files[4] in mgr._run_groups[0].Filenames())
   self.assertTrue(files[1] in mgr._run_groups[1].Filenames())
   self.assertTrue(files[5] in mgr._run_groups[1].Filenames())
   self.assertTrue(files[2] in mgr._run_groups[2].Filenames())
Exemplo n.º 10
0
  def testGetOffsetVariations(self):
    mgr = TestProfileManager({
        ProfileFile(40, 0, ''): [1, 2, 3],
        ProfileFile(50, 1, ''): [3, 4, 5],
        ProfileFile(51, 0, 'renderer'): [2, 3, 6],
        ProfileFile(51, 1, 'gpu-process'): [6, 7],
        ProfileFile(70, 0, ''): [2, 6, 8, 9],
        ProfileFile(70, 1, ''): [9]})
    phaser = phased_orderfile.PhasedAnalyzer(mgr, IdentityProcessor())
    offsets = phaser.GetOffsetsForMemoryFootprint()
    self.assertListEqual([1, 2, 8], offsets.startup)
    self.assertListEqual([6, 3, 9], offsets.common)
    self.assertListEqual([4, 5, 7], offsets.interaction)

    offsets = phaser.GetOffsetsForStartup()
    self.assertListEqual([1, 2, 6, 8], offsets.startup)
    self.assertListEqual([3, 9], offsets.common)
    self.assertListEqual([4, 5, 7], offsets.interaction)
Exemplo n.º 11
0
  def testGetCombinedProcessOffsets(self):
    mgr = TestProfileManager({
        ProfileFile(40, 0, ''): [1, 2, 3],
        ProfileFile(50, 1, ''): [3, 4, 5],
        ProfileFile(51, 0, 'renderer'): [2, 3, 6],
        ProfileFile(51, 1, 'gpu-process'): [6, 7],
        ProfileFile(70, 0, ''): [2, 8, 9],
        ProfileFile(70, 1, ''): [9]})
    phaser = phased_orderfile.PhasedAnalyzer(mgr, IdentityProcessor())
    offsets = phaser._GetCombinedProcessOffsets('browser')
    self.assertListEqual([1, 2, 8], sorted(offsets.startup))
    self.assertListEqual([4, 5], sorted(offsets.interaction))
    self.assertListEqual([3, 9], sorted(offsets.common))

    offsets = phaser._GetCombinedProcessOffsets('gpu-process')
    self.assertListEqual([], sorted(offsets.startup))
    self.assertListEqual([6, 7], sorted(offsets.interaction))
    self.assertListEqual([], sorted(offsets.common))

    self.assertListEqual(['browser', 'gpu-process', 'renderer'],
                         sorted(phaser._GetProcessList()))
Exemplo n.º 12
0
    def testClusterOffsetsFromCallGraph(self):
        process1 = ('{"call_graph": [ {'
                    '"callee_offset": "1000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "0",'
                    '"count": "2"'
                    '} ],'
                    '"index": "61496"'
                    '}, {'
                    '"callee_offset": "7000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "1000",'
                    '"count": "2"'
                    '}, {'
                    '"caller_offset": "7500",'
                    '"count": "100"'
                    '} ],'
                    '"index": "61500"'
                    '}, {'
                    '"callee_offset": "6000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "1000",'
                    '"count": "4"'
                    '}, {'
                    '"caller_offset": "7000",'
                    '"count": "3"'
                    '}, {'
                    '"caller_offset": "7500",'
                    '"count": "2"'
                    '}, {'
                    '"caller_offset": "0",'
                    '"count": "3"'
                    '} ],'
                    '"index": "47860"'
                    '}, {'
                    '"callee_offset": "3000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "6000",'
                    '"count": "11"'
                    '} ],'
                    '"index": "47900"'
                    '} ],'
                    '"total_calls_count": "127"'
                    '}')

        process2 = ('{"call_graph": [ {'
                    '"callee_offset": "1000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "0",'
                    '"count": "2"'
                    '} ],'
                    '"index": "61496"'
                    '}, {'
                    '"callee_offset": "5000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "1000",'
                    '"count": "20"'
                    '}, {'
                    '"caller_offset": "5000",'
                    '"count": "100"'
                    '}, {'
                    '"caller_offset": "3000",'
                    '"count": "40"'
                    '} ],'
                    '"index": "61500"'
                    '}, {'
                    '"callee_offset": "3000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "5000",'
                    '"count": "10"'
                    '}, {'
                    '"caller_offset": "0",'
                    '"count": "10"'
                    '} ],'
                    '"index": "47860"'
                    '} ],'
                    '"total_calls_count": "182"'
                    '}')

        process3 = ('{"call_graph": [ {'
                    '"callee_offset": "8000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "0",'
                    '"count": "5"'
                    '} ],'
                    '"index": "61496"'
                    '}, {'
                    '"callee_offset": "2000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "8000",'
                    '"count": "100"'
                    '} ],'
                    '"index": "61500"'
                    '}, {'
                    '"callee_offset": "4000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "8000",'
                    '"count": "20"'
                    '} ],'
                    '"index": "61504"'
                    '}, {'
                    '"callee_offset": "9000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "8000",'
                    '"count": "50"'
                    '} ],'
                    '"index": "61512"'
                    '}, {'
                    '"callee_offset": "7000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "2000",'
                    '"count": "15"'
                    '}, {'
                    '"caller_offset": "4000",'
                    '"count": "20"'
                    '}, {'
                    '"caller_offset": "9000",'
                    '"count": "80"'
                    '}, {'
                    '"caller_offset": "0",'
                    '"count": "400"'
                    '} ],'
                    '"index": "61516"'
                    '} ],'
                    '"total_calls_count": "690"'
                    '}')

        process4 = ('{"call_graph": [ {'
                    '"callee_offset": "8000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "0",'
                    '"count": "10"'
                    '} ],'
                    '"index": "61496"'
                    '}, {'
                    '"callee_offset": "2000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "8000",'
                    '"count": "100"'
                    '} ],'
                    '"index": "61500"'
                    '}, {'
                    '"callee_offset": "6000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "7000",'
                    '"count": "10"'
                    '} , {'
                    '"caller_offset": "7500",'
                    '"count": "2"'
                    '} ],'
                    '"index": "61504"'
                    '}, {'
                    '"callee_offset": "7000",'
                    '"caller_and_count": [ {'
                    '"caller_offset": "8000",'
                    '"count": "300"'
                    '}, {'
                    '"caller_offset": "7500",'
                    '"count": "100"'
                    '}, {'
                    '"caller_offset": "2000",'
                    '"count": "15"'
                    '}, {'
                    '"caller_offset": "0",'
                    '"count": "50"'
                    '} ],'
                    '"index": "61516"'
                    '} ],'
                    '"total_calls_count": "587"'
                    '}')

        processor = TestSymbolOffsetProcessor([
            SimpleTestSymbol('linker_script_start_of_text', 0, 0),
            SimpleTestSymbol('1', 1000, 999),
            SimpleTestSymbol('2', 2000, 999),
            SimpleTestSymbol('3', 3000, 999),
            SimpleTestSymbol('4', 4000, 16),
            SimpleTestSymbol('5', 5000, 16),
            SimpleTestSymbol('6', 6000, 999),
            SimpleTestSymbol('7', 7000, 16),
            SimpleTestSymbol('8', 7100, 0),  # whitelist
            SimpleTestSymbol('9', 8000, 999),
            SimpleTestSymbol('10', 9000, 16)
        ])
        mgr = TestProfileManager({
            ProfileFile(40, 0, 'renderer'):
            json.loads(process1),
            ProfileFile(50, 1, 'renderer'):
            json.loads(process2),
            ProfileFile(51, 0, 'browser'):
            json.loads(process3),
            ProfileFile(51, 1, 'gpu-process'):
            json.loads(process4)
        })
        syms = cluster.ClusterOffsets(mgr,
                                      processor,
                                      limit_cluster_size=False,
                                      call_graph=True)
        self.assertListEqual(['7', '6', '1', '5', '3', '9', '2', '10', '4'],
                             syms)