in reply to Fast coverage module or hack

First idea: if you load modules on demand — require at run-time instead of use at compile-time — then %INC will tell you what modules each test script has tested.

Second idea: the map probably doesn't change that often, so you don't need to update it every check-in. Check when it was last updated, and only run your test suite with Devel::Cover on to update the map if the map is stale by more than X hours. (X might be 6?) After a major refactoring, you might want to manually re-trigger the map to be regenerated.

Replies are listed 'Best First'.
Re^2: Fast coverage module or hack
by vsespb (Chaplain) on Dec 02, 2019 at 08:32 UTC
    First idea - no. we use "use" and compile time to load all stuff before "fork" webserver and to save memory with COW, so every module "use" maybe 80% of other modules.

    Second idea - yes we already do this. We run map collection once per day (before Devel::Cover is so slow for us). But when map changes, it actually can break things for rest of day. So we run map collection once per day, but also do git-diff to the commit where map collection was made, then there is no possibility of use of wrong map then, but diff gets bigger during the day. So we're looking how to speed up coverage module.

      How slow are we talking about? 10 minutes? An hour? 6 hours?

      Would doing the Devel::Cover run overnight instead of the day help?

        I think about 4 hours (run without devel cover is 40 mins). It can be run overnight, but any way it better to be run as often, as possible. Otherwise data not accurate.

        I am looking for alternative now. https://metacpan.org/pod/Devel::Trace (If I change printing lines to tracking lines) looks good.

      I think I have an idea for a solution but it would require a one-line change (a use statement added) to each module. Does that sound acceptable?

      My solution will need me to do a little work to figure out the details, but it seems like an interesting task to work on, and it might help me with one or two of my own projects.

      Edit: actually probably don't need a change to each module.

      Edit again: actually do.

        Does that sound acceptable?
        yes, it does. there can be a script which automatically add/replace lines in source files before test run.