Skip to content

Path::Tiny loads slower than other modules #321

Description

@scottchiefbaker

Using perl-module-startup-time.pl I'm able to calculate the startup time for Path::Tiny (no methods called, just loading the module) at 15.8ms. As a comparison here are some other modules on the same system.

   File::Basename adds  3.1 ms to startup time
      Time::HiRes adds  1.5 ms to startup time
   Getopt::Long adds    9.9 ms to startup time
     Data::Dumper adds  8.9 ms to startup time

That majority of the startup time in Path::Tiny is spent loading Carp and File::Spec. File::Spec is only used in rootdir(). Changing these two modules to load on-demand drops the startup time to 10.4ms. This is a ~34% improvement in startup time.

Before I go to the trouble of writing up a full PR is this something you'd consider accepting? Attached is a rough patch of the concept.

path-tiny-lazy-load.patch.gz

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions