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)
def _ProcessPhasedOrderfile(self, files): """Process the phased orderfiles produced by system health benchmarks. The offsets will be placed in _GetUnpatchedOrderfileFilename(). Args: file: Profile files pulled locally. """ self._step_recorder.BeginStep('Process Phased Orderfile') profiles = process_profiles.ProfileManager(files) processor = process_profiles.SymbolOffsetProcessor( self._compiler.lib_chrome_so) phaser = phased_orderfile.PhasedAnalyzer(profiles, processor) if self._options.offsets_for_memory: profile_offsets = phaser.GetOffsetsForMemoryFootprint() else: profile_offsets = phaser.GetOffsetsForStartup() self._output_data['orderfile_size'] = { 'startup_kib': processor.OffsetsPrimarySize(profile_offsets.startup) / 1024, 'common_kib': processor.OffsetsPrimarySize(profile_offsets.common) / 1024, 'interaction_kib': processor.OffsetsPrimarySize(profile_offsets.interaction) / 1024 } offsets_list = (profile_offsets.startup + profile_offsets.common + profile_offsets.interaction) ordered_symbols = processor.GetOrderedSymbols(offsets_list) if not ordered_symbols: raise Exception('Failed to get ordered symbols') with open(self._GetUnpatchedOrderfileFilename(), 'w') as orderfile: orderfile.write('\n'.join(ordered_symbols))
def main(): logging.basicConfig(level=logging.INFO) parser = _CreateArgumentParser() args = parser.parse_args() profiles = process_profiles.ProfileManager( itertools.chain.from_iterable( glob.glob(os.path.join(d, PROFILE_GLOB)) for d in args.profile_directory.split(','))) processor = process_profiles.SymbolOffsetProcessor( os.path.join(args.instrumented_build_dir, 'lib.unstripped', args.library_name)) phaser = PhasedAnalyzer(profiles, processor) stability = phaser.ComputeStability() print 'Stability: {:.2} {:.2} {:.2}'.format(*[s[0] for s in stability]) print 'Sizes: {} {} {}'.format(*[s[1] for s in stability]) if args.offset_output_base is not None: for name, offsets in zip(['_for_memory', '_for_startup'], [ phaser.GetOffsetsForMemoryFootprint(), phaser.GetOffsetsForStartup() ]): with file(args.offset_output_base + name, 'w') as output: output.write('\n'.join( str(i) for i in (offsets.startup + offsets.common + offsets.interaction))) output.write('\n')
def main(): logging.basicConfig(level=logging.INFO) parser = _CreateArgumentParser() args = parser.parse_args() profiles = process_profiles.ProfileManager( itertools.chain.from_iterable( glob.glob(os.path.join(d, PROFILE_GLOB)) for d in args.profile_directory.split(','))) processor = process_profiles.SymbolOffsetProcessor( os.path.join(args.instrumented_build_dir, 'lib.unstripped', args.library_name)) phaser = PhasedAnalyzer(profiles, processor) for name, offsets in (('_for_memory', phaser.GetOffsetsForMemoryFootprint()), ('_for_startup', phaser.GetOffsetsForStartup())): logging.info( '%s Offset sizes (KiB):\n' '%s startup\n%s common\n%s interaction', name, processor.OffsetsPrimarySize(offsets.startup) / 1024, processor.OffsetsPrimarySize(offsets.common) / 1024, processor.OffsetsPrimarySize(offsets.interaction) / 1024) if args.offset_output_base is not None: with file(args.offset_output_base + name, 'w') as output: output.write('\n'.join( str(i) for i in (offsets.startup + offsets.common + offsets.interaction))) output.write('\n')
def main(): logging.basicConfig(level=logging.INFO) parser = _CreateArgumentParser() args = parser.parse_args() profiles = process_profiles.ProfileManager( glob.glob(os.path.join(args.profile_directory, PROFILE_GLOB))) processor = process_profiles.SymbolOffsetProcessor(os.path.join( args.instrumented_build_dir, 'lib.unstripped', args.library_name)) phaser = PhasedAnalyzer(profiles, processor) print 'Stability: {:.2f} {:.2f} {:.2f}'.format(*phaser.ComputeStability())
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())
def _ProcessPhasedOrderfile(self, files): """Process the phased orderfiles produced by system health benchmarks. The offsets will be placed in _GetUnpatchedOrderfileFilename(). Args: file: Profile files pulled locally. """ self._step_recorder.BeginStep('Process Phased Orderfile') profiles = process_profiles.ProfileManager(files) processor = process_profiles.SymbolOffsetProcessor( self._compiler.lib_chrome_so) ordered_symbols = cluster.ClusterOffsets(profiles, processor) if not ordered_symbols: raise Exception('Failed to get ordered symbols') self._output_data['offsets_kib'] = processor.SymbolsSize( ordered_symbols) / 1024 with open(self._GetUnpatchedOrderfileFilename(), 'w') as orderfile: orderfile.write('\n'.join(ordered_symbols))
def _ProcessPhasedOrderfile(self, files): """Process the phased orderfiles produced by system health benchmarks. The offsets will be placed in _GetUnpatchedOrderfileFilename(). Args: file: Profile files pulled locally. """ self._step_recorder.BeginStep('Process Phased Orderfile') profiles = process_profiles.ProfileManager(files) processor = process_profiles.SymbolOffsetProcessor( self._compiler.lib_chrome_so) ordered_symbols = cluster.ClusterOffsets(profiles, processor) if not ordered_symbols: raise Exception('Failed to get ordered symbols') for sym in ordered_symbols: assert not sym.startswith('OUTLINED_FUNCTION_'), ( 'Outlined function found in instrumented function, very likely ' 'something has gone very wrong!') self._output_data['offsets_kib'] = processor.SymbolsSize( ordered_symbols) / 1024 with open(self._GetUnpatchedOrderfileFilename(), 'w') as orderfile: orderfile.write('\n'.join(ordered_symbols))