Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Compile Phase Time

by Anonymous Monk
on Apr 20, 2013 at 03:40 UTC ( #1029609=note: print w/replies, xml ) Need Help??

in reply to Compile Phase Time


#!/usr/bin/perl -- use strict; use warnings; use Module::Load ; use Time::HiRes qw/ time /; @ARGV or @ARGV = qw/ CGI B::Deparse DBI DBD::SQLite Moo Moose /; for my $mod( @ARGV ){ my $tb = time; load( $mod ); my $ta = time; printf "%.5f - %.5f = %.5f %s\n", $ta, $tb, $ta - $tb, $mod; } __END__ 1366428845.98106 - 1366428845.76563 = 0.21544 CGI 1366428846.11275 - 1366428845.98131 = 0.13144 B::Deparse 1366428846.15868 - 1366428846.11287 = 0.04581 DBI 1366428846.17056 - 1366428846.15895 = 0.01161 DBD::SQLite 1366428846.20396 - 1366428846.17067 = 0.03329 Moo 1366428846.71875 - 1366428846.20407 = 0.51468 Moose

Replies are listed 'Best First'.
Re^2: Compile Phase Time
by eye (Chaplain) on Apr 20, 2013 at 12:51 UTC
    Will this approach underestimate load times for modules later in the list when they share dependencies with modules earlier in the list?

      Yes, but it doesn't really matter , whole exercise is silly. This version won't, but it will fail at loading Moose twice (or after moo)

      #!/usr/bin/perl -- use strict; use warnings; use Module::Load ; use Time::HiRes qw/ time /; @ARGV or @ARGV = qw/ CGI B::Deparse DBI DBD::SQLite Moose Moo /; for my $mod( @ARGV ){ my $tb = time; { local $SIG{__WARN__} = sub{}; undef %INC; load( $mod ); } my $ta = time; printf "%.5f - %.5f = %.5f %s\n", $ta, $tb, $ta - $tb, $mod; } __END__ $ perl fudge Moose Moo CGI CGI CGI CGI 1366466283.45313 - 1366466282.70313 = 0.75000 Moose 1366466283.52620 - 1366466283.45344 = 0.07276 Moo 1366466283.63069 - 1366466283.52631 = 0.10438 CGI 1366466283.73354 - 1366466283.63081 = 0.10273 CGI 1366466283.83594 - 1366466283.73366 = 0.10228 CGI 1366466283.93854 - 1366466283.83606 = 0.10247 CGI
        Thank you folks for the valuable info. I really appreciate it.
        With every run this code returns a different result with the difference being between .1 - .2 s Any ideas why ?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1029609]
[oiskuu]: glibc getlogin just does ttyname() and falls back on getutline(); it's not security related at all. (reminds me of sendmail and remote finger services of the naive early spam era)
[Corion]: But yes, "who started this process" is interesting information :)
[tye]: no, I really believe that "login user" was added as a fundamental bit of info about each process in order to enhance the usefulness of auditing
[Corion]: Ah - if that information is saved in a file, then you could theoretically spam that file and confuse getlogin(). So, don't use it for authentication :)
[tye]: that is what getlogin() certainly *used* to do. I don't believe that is what it certainly should do.
[davido]: /var/run/utmp is 664 i think.
[tye]: Note that my "man getlogin" says that it uses stdin when it should use /dev/tty (calling a glibc bug). But that does not appear to be the case when I test it. But maybe Perl's getlogin() is not using glibc's getlogin().
[oiskuu]: well, run a strace and see what the getlogin does for you.... As I said. SELinux probably has those security labels. But not regular linux.
[tye]: for example, read https://unix. questions/146138/ loginuid-should-be -allowed-to-change -or-not-mutable-or -not
[tye]: I'm not using SELinux and it certainly appears to disagree with you. shrug

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2017-06-23 19:44 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (554 votes). Check out past polls.