← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Tue Nov 7 05:38:10 2017
Reported on Tue Nov 7 06:16:02 2017

Filename/usr/local/lib/perl5/site_perl/Mail/SpamAssassin/Message/Metadata.pm
StatementsExecuted 14959 statements in 92.0ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2351177.2ms3.74sMail::SpamAssassin::Message::Metadata::::extractMail::SpamAssassin::Message::Metadata::extract
11113.9ms215msMail::SpamAssassin::Message::Metadata::::BEGIN@59Mail::SpamAssassin::Message::Metadata::BEGIN@59
2351111.0ms11.0msMail::SpamAssassin::Message::Metadata::::finishMail::SpamAssassin::Message::Metadata::finish
235114.53ms4.53msMail::SpamAssassin::Message::Metadata::::newMail::SpamAssassin::Message::Metadata::new
11149µs59µsMail::SpamAssassin::Message::Metadata::::BEGIN@51Mail::SpamAssassin::Message::Metadata::BEGIN@51
11135µs235µsMail::SpamAssassin::Message::Metadata::::BEGIN@60Mail::SpamAssassin::Message::Metadata::BEGIN@60
11129µs29µsMail::SpamAssassin::Message::Metadata::::BEGIN@56Mail::SpamAssassin::Message::Metadata::BEGIN@56
11127µs96µsMail::SpamAssassin::Message::Metadata::::BEGIN@54Mail::SpamAssassin::Message::Metadata::BEGIN@54
11125µs32µsMail::SpamAssassin::Message::Metadata::::BEGIN@53Mail::SpamAssassin::Message::Metadata::BEGIN@53
11123µs164µsMail::SpamAssassin::Message::Metadata::::BEGIN@58Mail::SpamAssassin::Message::Metadata::BEGIN@58
11123µs56µsMail::SpamAssassin::Message::Metadata::::BEGIN@52Mail::SpamAssassin::Message::Metadata::BEGIN@52
11122µs798µsMail::SpamAssassin::Message::Metadata::::BEGIN@57Mail::SpamAssassin::Message::Metadata::BEGIN@57
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# <@LICENSE>
2# Licensed to the Apache Software Foundation (ASF) under one or more
3# contributor license agreements. See the NOTICE file distributed with
4# this work for additional information regarding copyright ownership.
5# The ASF licenses this file to you under the Apache License, Version 2.0
6# (the "License"); you may not use this file except in compliance with
7# the License. You may obtain a copy of the License at:
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# </@LICENSE>
17
18=head1 NAME
19
20Mail::SpamAssassin::Message::Metadata - extract metadata from a message
21
22=head1 SYNOPSIS
23
24=head1 DESCRIPTION
25
26This class is tasked with extracting "metadata" from messages for use as
27Bayes tokens, fodder for eval tests, or other rules. Metadata is
28supplemental data inferred from the message, like the examples below.
29
30It is held in two forms:
31
321. as name-value pairs of strings, presented in mail header format. For
33 example, "X-Language" => "en". This is the general form for simple
34 metadata that's useful as Bayes tokens, can be added to marked-up
35 messages using "add_header", etc., such as the trusted-relay inference
36 and language detection.
37
382. as more complex data structures on the $msg->{metadata} object. This
39 is the form used for metadata like the HTML parse data, which is stored
40 there for access by eval rule code. Because it's not simple strings,
41 it's not added as a Bayes token by default (Bayes needs simple strings).
42
43=head1 PUBLIC METHODS
44
45=over 4
46
47=cut
48
49package Mail::SpamAssassin::Message::Metadata;
50
51270µs269µs
# spent 59µs (49+10) within Mail::SpamAssassin::Message::Metadata::BEGIN@51 which was called: # once (49µs+10µs) by Mail::SpamAssassin::Message::BEGIN@56 at line 51
use strict;
# spent 59µs making 1 call to Mail::SpamAssassin::Message::Metadata::BEGIN@51 # spent 10µs making 1 call to strict::import
52260µs289µs
# spent 56µs (23+33) within Mail::SpamAssassin::Message::Metadata::BEGIN@52 which was called: # once (23µs+33µs) by Mail::SpamAssassin::Message::BEGIN@56 at line 52
use warnings;
# spent 56µs making 1 call to Mail::SpamAssassin::Message::Metadata::BEGIN@52 # spent 33µs making 1 call to warnings::import
53277µs239µs
# spent 32µs (25+7) within Mail::SpamAssassin::Message::Metadata::BEGIN@53 which was called: # once (25µs+7µs) by Mail::SpamAssassin::Message::BEGIN@56 at line 53
use bytes;
# spent 32µs making 1 call to Mail::SpamAssassin::Message::Metadata::BEGIN@53 # spent 7µs making 1 call to bytes::import
54277µs2165µs
# spent 96µs (27+69) within Mail::SpamAssassin::Message::Metadata::BEGIN@54 which was called: # once (27µs+69µs) by Mail::SpamAssassin::Message::BEGIN@56 at line 54
use re 'taint';
# spent 96µs making 1 call to Mail::SpamAssassin::Message::Metadata::BEGIN@54 # spent 69µs making 1 call to re::import
55
56268µs129µs
# spent 29µs within Mail::SpamAssassin::Message::Metadata::BEGIN@56 which was called: # once (29µs+0s) by Mail::SpamAssassin::Message::BEGIN@56 at line 56
use Mail::SpamAssassin;
57279µs21.58ms
# spent 798µs (22+777) within Mail::SpamAssassin::Message::Metadata::BEGIN@57 which was called: # once (22µs+777µs) by Mail::SpamAssassin::Message::BEGIN@56 at line 57
use Mail::SpamAssassin::Constants qw(:sa);
# spent 798µs making 1 call to Mail::SpamAssassin::Message::Metadata::BEGIN@57 # spent 777µs making 1 call to Exporter::import
58272µs2305µs
# spent 164µs (23+141) within Mail::SpamAssassin::Message::Metadata::BEGIN@58 which was called: # once (23µs+141µs) by Mail::SpamAssassin::Message::BEGIN@56 at line 58
use Mail::SpamAssassin::Util qw(reverse_ip_address);
# spent 164µs making 1 call to Mail::SpamAssassin::Message::Metadata::BEGIN@58 # spent 141µs making 1 call to Exporter::import
592404µs1215ms
# spent 215ms (13.9+202) within Mail::SpamAssassin::Message::Metadata::BEGIN@59 which was called: # once (13.9ms+202ms) by Mail::SpamAssassin::Message::BEGIN@56 at line 59
use Mail::SpamAssassin::Message::Metadata::Received;
602603µs2436µs
# spent 235µs (35+200) within Mail::SpamAssassin::Message::Metadata::BEGIN@60 which was called: # once (35µs+200µs) by Mail::SpamAssassin::Message::BEGIN@56 at line 60
use Mail::SpamAssassin::Logger;
# spent 235µs making 1 call to Mail::SpamAssassin::Message::Metadata::BEGIN@60 # spent 200µs making 1 call to Exporter::import
61
62=item new()
63
64=back
65
66=cut
67
68
# spent 4.53ms within Mail::SpamAssassin::Message::Metadata::new which was called 235 times, avg 19µs/call: # 235 times (4.53ms+0s) by Mail::SpamAssassin::Message::new at line 147 of Mail/SpamAssassin/Message.pm, avg 19µs/call
sub new {
69235567µs my ($class, $msg) = @_;
70235567µs $class = ref($class) || $class;
71
722351.32ms my $self = {
73 msg => $msg,
74 strings => { }
75 };
76
77235539µs bless($self,$class);
782358.63ms $self;
79}
80
81
# spent 3.74s (77.2ms+3.66) within Mail::SpamAssassin::Message::Metadata::extract which was called 235 times, avg 15.9ms/call: # 235 times (77.2ms+3.66s) by Mail::SpamAssassin::Message::extract_message_metadata at line 527 of Mail/SpamAssassin/Message.pm, avg 15.9ms/call
sub extract {
82235527µs my ($self, $msg, $permsgstatus) = @_;
83
84 # pre-chew Received headers
852352.26ms2353.49s $self->parse_received_headers ($permsgstatus, $msg);
# spent 3.49s making 235 calls to Mail::SpamAssassin::Message::Metadata::parse_received_headers, avg 14.9ms/call
86
872354.49ms foreach my $tuple (
88 [$self->{relays_trusted}, 'RELAYSTRUSTEDREVIP' ],
89 [$self->{relays_untrusted}, 'RELAYSUNTRUSTEDREVIP'],
90 [$self->{relays_internal}, 'RELAYSINTERNALREVIP' ],
91 [$self->{relays_external}, 'RELAYSEXTERNALREVIP' ])
929402.21ms { my($rly, $tag) = @$tuple;
939401.67ms my @revips;
94 @revips = map {
95303013.5ms my($ip,$revip);
96209010.6ms $ip = $_->{ip} if ref $_ && !$_->{ip_private};
97209010.3ms71840.8ms $revip = reverse_ip_address($ip) if defined $ip && $ip ne '';
# spent 40.8ms making 718 calls to Mail::SpamAssassin::Util::reverse_ip_address, avg 57µs/call
9820906.50ms defined $revip && $revip ne '' ? $revip : ();
99 } @$rly if $rly;
1009409.85ms46835.4ms $permsgstatus->set_tag($tag,
# spent 35.4ms making 468 calls to Mail::SpamAssassin::PerMsgStatus::set_tag, avg 76µs/call
101 @revips == 1 ? $revips[0] : \@revips) if @revips;
102 }
103
104 $permsgstatus->{main}->call_plugins("extract_metadata",
105 { msg => $msg, permsgstatus => $permsgstatus,
1062355.48ms2350s conf => $permsgstatus->{main}->{conf} });
# spent 92.4ms making 235 calls to Mail::SpamAssassin::call_plugins, avg 393µs/call, recursion: max depth 1, sum of overlapping time 92.4ms
107}
108
109
# spent 11.0ms within Mail::SpamAssassin::Message::Metadata::finish which was called 235 times, avg 47µs/call: # 235 times (11.0ms+0s) by Mail::SpamAssassin::Message::finish_metadata at line 605 of Mail/SpamAssassin/Message.pm, avg 47µs/call
sub finish {
110235517µs my ($self) = @_;
11147011.0ms %{$self} = ();
112}
113
11418µs1;