def main(): parser = argparse.ArgumentParser( description= "Graph the simulation results, using IPC to access the simulation's in-memory database." ) parser.add_argument('--use_db', type=str, default='false', help='set to "true to use database instead of IPC') args = parser.parse_args() use_db = args.use_db.lower() == "true" if use_db: conn = Db(DB_PATH) run = Run(db=conn) else: conn = Ipc() run = Run(ipc=conn) run_name = "run{}".format(run.run_id) run_dir = "{}/{}".format(IMG_DIR, run_name) if os.path.exists(run_dir): shutil.rmtree(run_dir) os.makedirs(run_dir) if use_db: graph_gen = GraphGen(run, db=conn, run_dir=run_dir) else: graph_gen = GraphGen(run, ipc=conn, run_dir=run_dir) graph_gen.plot_cumulative_best_fitness() graph_gen.plot_avg_fitness() conn.close()
def __init__(self, db_path): Gtk.Window.__init__(self, title='Viewer') self.set_default_size(ViewWindow.WIDTH, ViewWindow.HEIGHT) self.maximize() self.db = Db(db_path) self.run = Run(self.db) self.tree_gen = TreeGen(self.db) self.graph_gen = GraphGen(self.run, db=self.db) #we'll simulate an MRU (most recently used) cache using an OrderedDict #it's not the most efficient, but it's good enough for this application self.tree_cache = OrderedDict() self.grn_cache = OrderedDict() vbox = Gtk.VBox() paned = Gtk.Paned() left_scroll = Gtk.ScrolledWindow() self.tree_img = Gtk.Image() left_scroll.add_with_viewport(self.tree_img) paned.add1(left_scroll) right_scroll = Gtk.ScrolledWindow() self.grn_img = Gtk.Image() right_scroll.add_with_viewport(self.grn_img) paned.add2(right_scroll) paned.set_position(ViewWindow.WIDTH // 2) vbox.pack_start(paned, True, True, 0) vbox.pack_end(self._build_bottom_panel(), False, False, 0) self.add(vbox) self.show_all() self.update_views()
alloc_addr_space = addr_space revoker = BaseSweepingRevoker(10**20) else: alloc_state = AllocatedAddrSpaceModel() addr_space = MappedAddrSpaceModel() alloc_addr_space = AllocatorMappedAddrSpaceModel() m = re.search('([a-zA-Z]+)([0-9]+)?', args.sweeping_revoker) revoker_cls = globals()[m.group(1)] revoker = revoker_cls(*(m.group(2),) if m.group(2) is not None else (10**20,)) if args.colouring_revoker: revoker = ColouringRevoker(args.colouring_revoker, revoker) alloc_state.register_subscriber(revoker) # Set up the input processing run = Run(sys.stdin, trace_listeners=[alloc_state, addr_space, alloc_addr_space, revoker], addr_space_sample_listeners=[addr_space, ]) # Set up the output output = GraphOutput(sys.stdout) if args.allocation_map_output: alloc_map_output = AllocationMapOutput(args.allocation_map_output) output = CompositeOutput(output, alloc_map_output) if args.sweep_events_output: sweep_events_output = SweepEventsOutput(args.sweep_events_output) output = CompositeOutput(output, sweep_events_output) if args.rendered_allocation_map_output: from PIL import Image from PIL import ImageDraw from common.render import renderSpansZ rendered_alloc_map_output = RenderedAllocationMapOutput(args.rendered_allocation_map_output,
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #@file :run.py.py #@time :2020/4/22 18:27 #@Author :jmgen #@Version:1.0 #@Desc : import sys from common.run import Run from config.env import ENV """ run all case: python3 run_android.py run one module case: python3 run_android.py testcase/test_ui/test_account/test_addaccount.py python3 run_android.py testcase/test_ui run case with key word: python3 run_android.py -k <keyword> run class case: python3 run_android.py test/test_demo.py::Test_demo run class::method case: python3 run_android.py test/test_demo.py::Test_demo::test_home """ if __name__ == '__main__': run = Run() #获取命令行参数中的用例执行作用域 run.exec(sys.argv[1:]) run.generate_report(ENV)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #@file :run_android.py #@time :2020/4/17 9:47 #@Author :jmgen #@Version:1.0 #@Desc : import sys from common.run import Run from common.utils import Conf """ run all case: python3 run_android.py run one module case: python3 run_android.py testcase/test_ui/test_account/test_addaccount.py python3 run_android.py testcase/test_ui run case with key word: python3 run_android.py -k <keyword> run class case: python3 run_android.py test/test_demo.py::Test_demo run class::method case: python3 run_android.py test/test_demo.py::Test_demo::test_home """ if __name__ == '__main__': platformname = Conf().androidname #android or ios run = Run(platformname) #获取命令行参数中的用例执行作用域 run.exec(sys.argv[1:]) run.generate_report()
default=(1024, 1024)) argp.add_argument('remainder', nargs=argparse.REMAINDER, help="Arguments fed to allocator model") args = argp.parse_args() if args.stdouterr: sys.stderr.close() sys.stderr = sys.stdout # Set up logging logging.basicConfig(level=logging.getLevelName(args.log_level)) # Prepare Run run = Run(sys.stdin) tslam = lambda: run.timestamp_ns # This cannot possibly be the right answer allocspecs = importlib.util.find_spec(args.allocator) if allocspecs is None: allocspecs = importlib.util.find_spec("alloc." + args.allocator) if allocspecs is None: print("Unable to find allocator %s" % args.allocator, file=sys.stderr) sys.exit(1) allocmod = importlib.util.module_from_spec(allocspecs) allocspecs.loader.exec_module(allocmod) alloc = allocmod.Allocator(tslam=tslam, cliargs=args.remainder)
# Parse command line arguments argp = argparse.ArgumentParser( description='Sanitise a trace, fixing up inconsistencies.') argp.add_argument("--log-level", help="Set the logging level. Defaults to CRITICAL", choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], default="CRITICAL") args = argp.parse_args() # Set up logging logging.basicConfig(level=logging.getLevelName(args.log_level), format="%(message)s") logger = logging.getLogger() # XXX-LPT: ideally, it should be possible to register an Unrun as a Run listener, # but Unrun's interface is spoiled with the "publisher" argument from the # Publisher/Subscriber interface (which is actually more of an Observee/Observer). # The issue can be mended by e.g. changing the publisher argument to an optional # (perhaps keyword) argument. # But I believe the Publisher/Subscriber is overused in the first place, I believe # it shouldn't be used when there's only one potential subscriber, like there is # for the allocators' rewrite pipeline. fixups = TraceFixups() run = Run(sys.stdin, trace_listeners=[fixups], addr_space_sample_listeners=[fixups]) trace = Unrun(lambda: run.timestamp_ns, sys.stdout) #run.register_addr_space_sample_listener(trace) run.replay()
(oid, atid, asz, stkid, ats, irt, fts, ftid, sftf)) na += 1 nr = 0 def ir(oid, rmd, fts, sftf): global nr (rstk, rtid, rts, rosz, rnsz) = rmd stkid = istk(rstk) con.execute( "INSERT INTO reallocs " "(oid,rtid,osz,nsz,stkid,ats,fts,sftf) VALUES (?,?,?,?,?,?,?,?)", (oid, rtid, rosz, rnsz, stkid, rts, fts, sftf)) nr += 1 run = Run(sys.stdin) if args.just_stacks: run._trace_listeners += [JustStacks(istk)] run.replay() else: tslam = lambda: run.timestamp_ns at = MetadataTracker(tslam, istk, ia, ir) run._trace_listeners += [at] run.replay() con.execute(kviq, ("firsttime", run.timestamp_initial_ns)) con.execute(kviq, ("lasttime", run.timestamp_ns)) at._tslam = lambda: None at.finish()