Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8889319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:13:56+00:00 2026-06-14T22:13:56+00:00

When I was looking at the output of Devel::NYTProf v4 for a CGI program

  • 0

When I was looking at the output of Devel::NYTProf v4 for a CGI program, I came across the diagnostics.pm in the report Source Code Files — ordered by exclusive time then name.

diagnostics.pm

First I didn’t understand why that would be in the production code. I dug deeper through the report and found out that it was called by main::BEGIN@17. That, in turn, is the following line:

# spent 34µs (26+8) within main::BEGIN@15 which was called: # once (26µs+8µs) by main::RUNTIME at line 15
use strict;
# spent 34µs making 1 call to main::BEGIN@15 # spent 8µs making 1 call to strict::import

# spent 36µs (17+19) within main::BEGIN@16 which was called: # once (17µs+19µs) by main::RUNTIME at line 16
use warnings;

# spent 36µs making 1 call to main::BEGIN@16 # spent 19µs making 1 call to warnings::import

# spent 292ms (171+121) within main::BEGIN@17 which was called: # once (171ms+121ms) by main::RUNTIME at line 17
no diagnostics;
# spent 292ms making 1 call to main::BEGIN@17

# spent 135µs (27+108) within main::BEGIN@18 which was called: # once (27µs+108µs) by main::RUNTIME at line 18
use Carp qw( carp croak );

So this seems to be the culprit. I removed the no diagnostics line, and the call was gone, effectively saving about 300ms of time.

Here’s what perldoc use says about the no keyword:

There’s a corresponding no declaration that unimports meanings
imported by use, i.e., it calls unimport Module LIST instead of
import. It behaves just as import does with VERSION, an omitted or
empty LIST, or no unimport method being found.

no integer;
no strict 'refs';
no warnings;

So here’s my actual question: Am I correct in assuming that if I call no diagnostics, it is actually loaded before it is unimported?

Is the call to no diagnostics similar to this piece of code?

BEGIN {
  require diagnostics.pm;
  diagnostics->unimport;
}

In consequence, is it a bad idea to just unimport stuff that has never been imported, because that actually loads it first?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:13:58+00:00Added an answer on June 14, 2026 at 10:13 pm

    Am I correct in assuming that if I call no diagnostics, it is actually loaded before it is unimported?

    Yes. Its indeed full equivalent to

    BEGIN {
      require diagnostics;
      diagnostics->unimport;
    }
    

    So no module command actually loads and compiles the module; including executing the code which is not in any sub, in BEGIN block etc; same for all dependencies of given module(for every use/ require inside).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking to compare multiple CSV files with Python, and output a report.
I was looking at the output of some stuff from UglifyJS and happened across
I am starting to learn about makefiles. Looking at the output I see a
We are looking to sum the output of an expression meaning that it does
I am looking for a way to output an instantiated class, an Object to
I'm looking to generate an output similar to this: 1. One 2. Two 3.
Looking for an awk (or sed) one-liner to remove lines from the output if
I am looking for a way to have output in the same manner as
I'm looking for a way to send the output of an arbitrary Emacs command
I'm looking for some LaTeX template for creating quality output. On R-bloggers I've bumped

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.