Esempio n. 1
0
    def test_profile(self):
        prof = Profiler()
        prof.start()
        try:
            Tester1().t1()
        finally:
            prof.done()

        self.assertNotEqual(os.path.getsize('python-profiler-result.jandy'), 0)
        with open("python-profiler-result.jandy", "r") as file:
            context = json.load(file)

        print(context)
        self.assertIsNotNone(context['rootId'])
        self.assertEquals(len(context['nodes']), 3)

        self.assertEquals(len([n for n in context['nodes'] if n['parentId'] is not None]), 2)
Esempio n. 2
0
def main():
    if len(sys.argv) < 1:
        usage()
        sys.exit(2)

    sys.argv[:] = sys.argv[1:]
    progname = sys.argv[0]
    with open(progname, "rb") as f:
        sys.path.insert(0, os.path.dirname(progname))
        code = compile(f.read(), progname, "exec")
        pr = Profiler()
        pr.start()
        sub_globals = {
            '__file__': progname,
            '__name__': '__main__',
            '__package__': None
        }
        sub_locals = {}
        try:
                exec(code, sub_globals, sub_locals)
        finally:
            pr.done()
Esempio n. 3
0
    def test_profile(self):
        prof = Profiler()
        prof.start()
        try:
            Tester1().t1()
        finally:
            prof.done()

        self.assertNotEqual(os.path.getsize('python-profiler-result.jandy'), 0)
        with open("python-profiler-result.jandy", "r") as file:
            trans = TFileObjectTransport(file)
            context = ProfilingContext()
            context.read(TJSONProtocol(trans))

        print(context)
        self.assertIsNotNone(context.root)
Esempio n. 4
0
    def test_profile(self):
        prof = Profiler()
        prof.start()
        try:
            Tester1().t1()
        finally:
            prof.done()

        self.assertNotEqual(os.path.getsize('python-profiler-result.jandy'), 0)
        with open("python-profiler-result.jandy", "r") as file:
            context = json.load(file)

        print(context)
        self.assertIsNotNone(context['rootId'])
        self.assertEquals(len(context['nodes']), 3)

        self.assertEquals(
            len([n for n in context['nodes'] if n['parentId'] is not None]), 2)
Esempio n. 5
0
File: main.py Progetto: syjsmk/jandy
def main():
    if len(sys.argv) < 1:
        usage()
        sys.exit(2)

    sys.argv[:] = sys.argv[1:]
    progname = sys.argv[0]
    with open(progname, "rb") as f:
        sys.path.insert(0, os.path.dirname(progname))
        code = compile(f.read(), progname, "exec")
        pr = Profiler()
        pr.start()
        sub_globals = {
            '__file__': progname,
            '__name__': '__main__',
            '__package__': None
        }
        sub_locals = {}
        try:
            exec(code, sub_globals, sub_locals)
        finally:
            pr.done()
Esempio n. 6
0
def main():
    batchSize = sys.argv[1]
    baseUrl = sys.argv[2]
    id = sys.argv[3]

    sys.argv = sys.argv[4:]

    progname = sys.argv[0]
    with open(progname, "rb") as f:
        sys.path.insert(0, os.path.dirname(progname))
        code = compile(f.read(), progname, "exec")
        pr = Profiler(batchSize, baseUrl, id)
        pr.start()
        sub_globals = {
            '__file__': progname,
            '__name__': '__main__',
            '__package__': None
        }
        sub_locals = {}
        try:
            six.exec_(code, sub_globals, sub_locals)
        finally:
            pr.done()