Package omero :: Package plugins :: Module perf
[hide private]
[frames] | no frames]

Source Code for Module omero.plugins.perf

 1  #!/usr/bin/env python 
 2  """ 
 3     Plugin for measuring the performance of an OMERO 
 4     installation. 
 5   
 6     Plugin read by omero.cli.Cli during initialization. The method(s) 
 7     defined here will be added to the Cli class for later use. 
 8   
 9     Copyright 2008 Glencoe Software, Inc. All rights reserved. 
10     Use is subject to license terms supplied in LICENSE.txt 
11   
12  """ 
13   
14  import sys 
15  from omero.cli import BaseControl, CLI 
16  from omero_ext.argparse import FileType 
17  import omero.install.perf_test as perf_test 
18   
19  HELP = """Run perf_test files 
20   
21  %s 
22   
23  """ % perf_test.FILE_FORMAT 
24   
25 -class PerfControl(BaseControl):
26
27 - def _configure(self, parser):
28 parser.add_argument("-l", "--list", action="store_true", help="List available commands") 29 parser.add_argument("file", nargs="*", type=FileType('r'), default=None, help="Read from files or standard in") 30 parser.set_defaults(func=self.__call__)
31
32 - def __call__(self, args):
33 if args.list: 34 ops = [ x[4:] for x in dir(perf_test.Item) if x.startswith("_op_") ] 35 ops.sort() 36 for op in ops: 37 print op 38 else: 39 if not args.file: 40 self.ctx.die(167, "No files given. Use '-' for stdin.") 41 client = self.ctx.conn(args) 42 ctx = perf_test.Context(None, client = client) 43 self.ctx.out("Saving performance results to %s" % ctx.dir) 44 ctx.add_reporter(perf_test.CsvReporter(ctx.dir)) 45 #ctx.add_reporter(perf_test.HdfReporter(ctx.dir)) 46 #ctx.add_reporter(perf_test.PlotReporter()) 47 handler = perf_test.PerfHandler(ctx) 48 perf_test.handle(handler, args.file)
49 50 try: 51 register("perf", PerfControl, HELP) 52 except NameError: 53 if __name__ == "__main__": 54 cli = CLI() 55 cli.register("perf", PerfControl, HELP) 56 cli.invoke(sys.argv[1:]) 57