Re: [Zope-dev] coverage.py, profile and hotshot support in Zope's testrunner
Stefane Fermigier wrote: Sidnei da Silva wrote: On Sun, Aug 21, 2005 at 10:20:28AM +0200, Stefane Fermigier wrote: | I have added support for coverage analysis using coverage.py from Gareth | Rees and Ned Batchelder, as well as support for profiling using either the | profile or hotshot modules from the Python standard library, to Zope 2's | test runner test.py. | | Justification: | | - coverage.py will let you interactively focus on the modules you want to | check for coverage. | | - profile is slow to collect data but quick for analysis. | | - hotshot is fast when collecting but very slow for analysis. On the other | hand, one can feed the great KCacheGrind tool with hotshot data after some | transformation and this is the best way I have found so far for | interactively exploring profile data. Eerm, the test runner in Zope 2 is the same from Zope 3. The version in Zope 3 X3.0 has profile support using hotshot and coverage support using the trace.py module, but the version in Zope 2 is earlier than that. How does that differ from what you're proposing? 1. I haven't found hotshot support in either Zope 2.8.1 nor the TRUNK. 2. Has I wrote, coverage.py can be used interactively (at least, from the command line) to focus on whichever package you are working on at the moment. You can also collect data from several runs, which is useful for us because we have to test each CPS package in a different run. 3. I understand that trace.py and coverage.py have some overlap, and should probably be merged into one great and up to date coverage tool. But before it is done, I find useful to have both tools at our disposal. 4. Same for hotshot and profile. Both are useful. I don't think Sidnei was questioning the value of these, but just pointing out that another version of the test runner already had some of this. I'll note that I'm working on a newer test runner that I hope to use in Zope 2.9 and 3.2. The new test runner is a nearly complete rewrite to provide: - A more flexible test runner that can be used for a variety of projects. The current test runner has been forked for ZODB, Zope 3, and Zope 2. That's why the Zope 3 version has features that are lacking in the Zope 2 version. - Support for layers of tests, so that it can handle unit tests and functional tests. - A slightly better UI. - Tests (of the test runner itself :) See: http://svn.zope.org/zope.testing/trunk/src/zope/testing/testrunner.txt?view=log http://svn.zope.org/zope.testing/trunk/src/zope/testing/testrunner.py?view=log I'd like to include coverage and profiling support. (There is partial support now, but untested.) Wanna help? Jim -- Jim Fulton mailto:[EMAIL PROTECTED] Python Powered! CTO (540) 361-1714http://www.python.org Zope Corporation http://www.zope.com http://www.zope.org ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] coverage.py, profile and hotshot support in Zope's testrunner
I have added support for coverage analysis using coverage.py from Gareth Rees and Ned Batchelder, as well as support for profiling using either the profile or hotshot modules from the Python standard library, to Zope 2's test runner test.py. Justification: - coverage.py will let you interactively focus on the modules you want to check for coverage. - profile is slow to collect data but quick for analysis. - hotshot is fast when collecting but very slow for analysis. On the other hand, one can feed the great KCacheGrind tool with hotshot data after some transformation and this is the best way I have found so far for interactively exploring profile data. Since I'm not a regular Zope commiter, I'd like to ask for comments and permission first before commiting. The test.py file is here: http://blogs.nuxeo.com/sections/blogs/fermigier/2005_08_21_coverage-py-profile BTW: the patch is absolutely trivial (see attached file). S. -- Stéfane Fermigier, Tel: +33 (0)6 63 04 12 77 (mobile). Nuxeo Collaborative Portal Server: http://www.nuxeo.com/cps Gestion de contenu web / portail collaboratif / groupware / open source! 1c1 #!/home/fermigier/bin/python --- #!/usr/bin/env python2.3 124,143d123 --coverage Use the coverage.py module from Gareth Rees (http://www.nedbatchelder.com/code/modules/coverage.html) to collect data for code coverage. This will output trace data in a file called '.coverage'. You will need to call coverage.py after the test run to analyse the data (-r for a line count report, -a for annotated file). --profile Use the profile module from the standard library to collect profiling data. This will output data in a file called '.profile'. You will need to use the pstats module from the standard library after the test run to analyse the data. --hotshot Use the hotshot module from the standard library to collect profiling data. This will output data in a file called '.hotshot'. You will need to use the hotshot.pstats module from the standard library after the test run to analyse the data. You may also use the hotshot2cg script from the KCacheGrind sources to create data suitable for analysis by KCacheGrind. 772,774d751 COVERAGE = False PROFILE = False HOTSHOT = False 797,798c774 config-file=, import-testing, coverage, profile, hotshot]) --- config-file=, import-testing]) 850,855d825 elif k == --coverage: COVERAGE = True elif k == --profile: PROFILE = True elif k == --hotshot: HOTSHOT = True 936,958d905 elif COVERAGE: try: from coverage import the_coverage except: print You need to install coverage.py from print http://www.nedbatchelder.com/code/modules/coverage.html; sys.exit() the_coverage.start() main(module_filter, test_filter, libdir) elif PROFILE: import profile profile.runctx(main(module_filter, test_filter, libdir), globals=globals(), locals=vars(), filename=.profile) elif HOTSHOT: import hotshot profile = hotshot.Profile(.hotshot) profile.runctx(main(module_filter, test_filter, libdir), globals=globals(), locals=vars()) begin:vcard fn:Stefane Fermigier n:Fermigier;Stefane org:Nuxeo adr:;;14, rue Soleillet;Paris;;75020;France email;internet:[EMAIL PROTECTED] title:Directeur / CEO tel;work:+33 1 40 33 79 87 tel;fax:+33 1 43 58 14 15 tel;cell:+33 6 63 04 12 77 x-mozilla-html:FALSE url:http://www.nuxeo.com/ version:2.1 end:vcard ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] coverage.py, profile and hotshot support in Zope's testrunner
--On 21. August 2005 10:20:28 +0200 Stefane Fermigier [EMAIL PROTECTED] wrote: Since I'm not a regular Zope commiter, I'd like to ask for comments and permission first before commiting. The test.py file is here: http://blogs.nuxeo.com/sections/blogs/fermigier/2005_08_21_coverage-py-pr ofile Looks fine to me. At least put it on the trunk. If others find it useful as well, put it on the 2.8 branch. Andreas pgpmgGffBLyqv.pgp Description: PGP signature ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] coverage.py, profile and hotshot support in Zope's testrunner
On Sun, Aug 21, 2005 at 10:20:28AM +0200, Stefane Fermigier wrote: | I have added support for coverage analysis using coverage.py from Gareth | Rees and Ned Batchelder, as well as support for profiling using either the | profile or hotshot modules from the Python standard library, to Zope 2's | test runner test.py. | | Justification: | | - coverage.py will let you interactively focus on the modules you want to | check for coverage. | | - profile is slow to collect data but quick for analysis. | | - hotshot is fast when collecting but very slow for analysis. On the other | hand, one can feed the great KCacheGrind tool with hotshot data after some | transformation and this is the best way I have found so far for | interactively exploring profile data. Eerm, the test runner in Zope 2 is the same from Zope 3. The version in Zope 3 X3.0 has profile support using hotshot and coverage support using the trace.py module, but the version in Zope 2 is earlier than that. How does that differ from what you're proposing? -- Sidnei da Silva Enfold Systems, LLC. http://enfoldsystems.com ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] coverage.py, profile and hotshot support in Zope's testrunner
Sidnei da Silva wrote: On Sun, Aug 21, 2005 at 10:20:28AM +0200, Stefane Fermigier wrote: | I have added support for coverage analysis using coverage.py from Gareth | Rees and Ned Batchelder, as well as support for profiling using either the | profile or hotshot modules from the Python standard library, to Zope 2's | test runner test.py. | | Justification: | | - coverage.py will let you interactively focus on the modules you want to | check for coverage. | | - profile is slow to collect data but quick for analysis. | | - hotshot is fast when collecting but very slow for analysis. On the other | hand, one can feed the great KCacheGrind tool with hotshot data after some | transformation and this is the best way I have found so far for | interactively exploring profile data. Eerm, the test runner in Zope 2 is the same from Zope 3. The version in Zope 3 X3.0 has profile support using hotshot and coverage support using the trace.py module, but the version in Zope 2 is earlier than that. How does that differ from what you're proposing? 1. I haven't found hotshot support in either Zope 2.8.1 nor the TRUNK. 2. Has I wrote, coverage.py can be used interactively (at least, from the command line) to focus on whichever package you are working on at the moment. You can also collect data from several runs, which is useful for us because we have to test each CPS package in a different run. 3. I understand that trace.py and coverage.py have some overlap, and should probably be merged into one great and up to date coverage tool. But before it is done, I find useful to have both tools at our disposal. 4. Same for hotshot and profile. Both are useful. S. -- Stéfane Fermigier, Tel: +33 (0)6 63 04 12 77 (mobile). Nuxeo Collaborative Portal Server: http://www.nuxeo.com/cps Gestion de contenu web / portail collaboratif / groupware / open source! begin:vcard fn:Stefane Fermigier n:Fermigier;Stefane org:Nuxeo adr:;;14, rue Soleillet;Paris;;75020;France email;internet:[EMAIL PROTECTED] title:Directeur / CEO tel;work:+33 1 40 33 79 87 tel;fax:+33 1 43 58 14 15 tel;cell:+33 6 63 04 12 77 x-mozilla-html:FALSE url:http://www.nuxeo.com/ version:2.1 end:vcard ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )